Class SingleOrEnumerable<T>
- Namespace
- Garyon.Objects.Enumerators
- Assembly
- Garyon.dll
Represents either a single value, an enumerable, or no value at all.
public class SingleOrEnumerable<T> : IEnumerable<T>, IEnumerable
Type Parameters
TThe type of the stored value(s).
- Inheritance
-
SingleOrEnumerable<T>
- Implements
-
IEnumerable<T>
- Inherited Members
- Extension Methods
Constructors
SingleOrEnumerable()
public SingleOrEnumerable()
SingleOrEnumerable(IEnumerable<T>)
public SingleOrEnumerable(IEnumerable<T> enumerable)
Parameters
enumerableIEnumerable<T>
SingleOrEnumerable(T)
public SingleOrEnumerable(T value)
Parameters
valueT
Properties
Enumerable
Gets or sets the enumerable values of this instance.
public IEnumerable<T> Enumerable { get; set; }
Property Value
- IEnumerable<T>
Remarks
If the Kind property does not return
Enumerable, an exception is
thrown.
Setting the enumerable values automatically adjusts the kind of the
stored value to Enumerable.
Exceptions
- InvalidOperationException
Thrown when the current kind is not Enumerable when trying to get the enumerable values.
Kind
Gets the kind of value(s) stored in this instance.
public SingleOrEnumerableKind Kind { get; }
Property Value
Single
Gets or sets the single value of this instance.
public T Single { get; set; }
Property Value
- T
Remarks
If the Kind property does not return
Single, an exception is thrown.
Setting the single value automatically adjusts the kind of the stored
value to Single.
Exceptions
- InvalidOperationException
Thrown when the current kind is not Single when trying to get the single value.
Methods
Assign(SingleOrEnumerable<T>)
public void Assign(SingleOrEnumerable<T> other)
Parameters
otherSingleOrEnumerable<T>
Assign(IEnumerable<T>)
public void Assign(IEnumerable<T> value)
Parameters
valueIEnumerable<T>
Assign(T)
public void Assign(T value)
Parameters
valueT
GetEnumerator()
Returns an enumerator for this instance.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
- Instance for None
- A SingleValueEnumerator<T> instance for Single
- The enumerable values' enumerator instance for Enumerable
Reset()
Sets the kind of the stored values to None.
public void Reset()