Table of Contents

Class SwitchExtensions

Namespace
System.Linq
Assembly
Arc4u.dll

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

source IEnumerable<TSource>

The sequence to project.

Returns

Switch<TSource, TResult>

A Switch<TSource, TResult> to which cases can be added.

Type Parameters

TSource

The type of the elements of the source sequence.

TResult

The type of the produced elements.

Exceptions

ArgumentNullException

source is 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

source IEnumerable<TSource>

The sequence to project.

predicate Func<TSource, bool>

Returns true when the element belongs to the case.

selector Func<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

TSource

The type of the elements of the source sequence.

TResult

The type of the produced elements.

Exceptions

ArgumentNullException

source, predicate or selector is 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

source IEnumerable<TSource>

The sequence to project.

type Type

The type of the elements that belong to the case.

selector Func<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

TSource

The type of the elements of the source sequence.

TResult

The type of the produced elements.

Exceptions

ArgumentNullException

source, type or selector is null.