Class SwitchExtensions
Extension methods to start a Switch<TSource, TResult> on any sequence.
public static class SwitchExtensions
- Inheritance
-
SwitchExtensions
- Inherited Members
Methods
AsSwitch<TSource, TResult>(IEnumerable<TSource>)
Starts a Switch<TSource, TResult> on a sequence, without any case.
public static Switch<TSource, TResult> AsSwitch<TSource, TResult>(this IEnumerable<TSource> source)
Parameters
sourceIEnumerable<TSource>The sequence to project.
Returns
- Switch<TSource, TResult>
A Switch<TSource, TResult> to which cases can be added.
Type Parameters
TSourceThe type of the elements of the source sequence.
TResultThe type of the produced elements.
Exceptions
- ArgumentNullException
sourceis null.
Case<TSource, TResult>(IEnumerable<TSource>, Func<TSource, bool>, Func<TSource, TResult>)
Starts a Switch<TSource, TResult> on a sequence with a first case selected by a predicate.
public static Switch<TSource, TResult> Case<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, Func<TSource, TResult> selector)
Parameters
sourceIEnumerable<TSource>The sequence to project.
predicateFunc<TSource, bool>Returns true when the element belongs to the case.
selectorFunc<TSource, TResult>Produces the result for an element that belongs to the case.
Returns
- Switch<TSource, TResult>
A Switch<TSource, TResult> to which other cases can be added.
Type Parameters
TSourceThe type of the elements of the source sequence.
TResultThe type of the produced elements.
Exceptions
- ArgumentNullException
source,predicateorselectoris null.
Case<TSource, TResult>(IEnumerable<TSource>, Type, Func<TSource, TResult>)
Starts a Switch<TSource, TResult> on a sequence with a first case selected by type.
public static Switch<TSource, TResult> Case<TSource, TResult>(this IEnumerable<TSource> source, Type type, Func<TSource, TResult> selector)
Parameters
sourceIEnumerable<TSource>The sequence to project.
typeTypeThe type of the elements that belong to the case.
selectorFunc<TSource, TResult>Produces the result for an element that belongs to the case.
Returns
- Switch<TSource, TResult>
A Switch<TSource, TResult> to which other cases can be added.
Type Parameters
TSourceThe type of the elements of the source sequence.
TResultThe type of the produced elements.
Exceptions
- ArgumentNullException
source,typeorselectoris null.