Table of Contents

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

T

The type of the stored value(s).

Inheritance
SingleOrEnumerable<T>
Implements
Inherited Members
Extension Methods

Constructors

SingleOrEnumerable()

public SingleOrEnumerable()

SingleOrEnumerable(IEnumerable<T>)

public SingleOrEnumerable(IEnumerable<T> enumerable)

Parameters

enumerable IEnumerable<T>

SingleOrEnumerable(T)

public SingleOrEnumerable(T value)

Parameters

value T

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

SingleOrEnumerableKind

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

other SingleOrEnumerable<T>

Assign(IEnumerable<T>)

public void Assign(IEnumerable<T> value)

Parameters

value IEnumerable<T>

Assign(T)

public void Assign(T value)

Parameters

value T

GetEnumerator()

Returns an enumerator for this instance.

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

Reset()

Sets the kind of the stored values to None.

public void Reset()