Class DerivedTypeUnionCollection
- Namespace
- Nerdbank.MessagePack
- Assembly
- Nerdbank.MessagePack.dll
An immutable collection of DerivedTypeUnion objects.
public class DerivedTypeUnionCollection : IReadOnlyCollection<DerivedTypeUnion>, IEnumerable<DerivedTypeUnion>, IEnumerable
- Inheritance
-
DerivedTypeUnionCollection
- Implements
- Inherited Members
Remarks
Since the DerivedTypeUnion object is mutable and this collection must be immutable, we freeze the result of each union as it is added, and that is what is used during serialization. If the original DerivedTypeUnion object mutates later, serialization will be unaffected.
Properties
Count
Gets the number of elements in the collection.
public int Count { get; }
Property Value
- int
The number of elements in the collection.
Methods
Create(ReadOnlySpan<DerivedTypeUnion>)
Constructs a new DerivedTypeUnionCollection from a collection of DerivedShapeMapping<TBase> objects.
public static DerivedTypeUnionCollection Create(ReadOnlySpan<DerivedTypeUnion> derivedTypeUnions)
Parameters
derivedTypeUnions
ReadOnlySpan<DerivedTypeUnion>The unions to fill the collection with. These objects become frozen when they are added to this collection such that any attempt to mutate them later will throw an exception.
Returns
- DerivedTypeUnionCollection
A new instance of DerivedTypeUnionCollection.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public ImmutableArray<DerivedTypeUnion>.Enumerator GetEnumerator()
Returns
- ImmutableArray<DerivedTypeUnion>.Enumerator
An enumerator that can be used to iterate through the collection.