Noda Time
Show / Hide Table of Contents

Class CompositePatternBuilder<T>

A builder for composite patterns.
Since 2.0.x
Availability netstandard2.0
Inheritance
Object
CompositePatternBuilder<T>
Implements
IEnumerable<IPattern<T>>
IEnumerable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: NodaTime.Text
Assembly: NodaTime.dll
Syntax
public sealed class CompositePatternBuilder<T> : IEnumerable<IPattern<T>>, IEnumerable
Type Parameters
Name Description
T The type of value to be parsed or formatted by the resulting pattern.
Remarks
A composite pattern is a combination of multiple patterns. When parsing, these are checked in the order in which they are added to the builder with the Add(IPattern<T>, Func<T, Boolean>) method, by trying to parse and seeing if the result is a successful one. When formatting, the patterns are checked in the reverse order, using the predicate provided along with the pattern when calling Add. The intention is that patterns are added in "most precise first" order, and the predicate should indicate whether it can fully represent the given value - so the "less precise" (and therefore usually shorter) pattern can be used first.

Constructors

CompositePatternBuilder()

Constructs a new instance which initially has no component patterns. At least one component pattern must be added before Build() is called.
Since 2.1.x
Availability netstandard2.0
Declaration
public CompositePatternBuilder()

Methods

Add(IPattern<T>, Func<T, Boolean>)

Adds a component pattern to this builder.
Since 2.0.x
Availability netstandard2.0
Declaration
public void Add(IPattern<T> pattern, Func<T, bool> formatPredicate)
Parameters
Type Name Description
IPattern<T> pattern The component pattern to use as part of the eventual composite pattern.
Func<T, Boolean> formatPredicate A predicate to determine whether or not this pattern is suitable for formatting the given value.

Build()

Builds a composite pattern from this builder. Further changes to this builder will have no impact on the returned pattern.
Since 2.0.x
Availability netstandard2.0
Declaration
public IPattern<T> Build()
Returns
Type Description
IPattern<T> A pattern using the patterns added to this builder.
Exceptions
Type Condition
System.InvalidOperationException No component patterns have been added.

Explicit Interface Implementations

IEnumerable<IPattern<T>>.GetEnumerator()

Since 2.0.x
Availability netstandard2.0
Declaration
IEnumerator<IPattern<T>> IEnumerable<IPattern<T>>.GetEnumerator()
Returns
Type Description
IEnumerator<IPattern<T>>

IEnumerable.GetEnumerator()

Since 2.0.x
Availability netstandard2.0
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
IEnumerator

Implements

System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
In this article
Back to top Generated by DocFX