FluentExtensions Class

Provides generic extension methods to perform simple operations with fluent syntax.

public static class FluentExtensions

Methods

NameDescription
T.Chain(FluentAction<T>)Invokes a chainable method on an object.
T.Chain<TArg>(TArg, FluentAction<T, TArg>)Invokes a chainable method on an object and an additional argument.
T.Chain<TArg1, TArg2>(TArg1, TArg2, FluentAction<T, TArg1, TArg2>)Invokes a chainable method on an object and additional arguments.
T.Chain<TArg1, TArg2, TArg3>(TArg1, TArg2, TArg3, FluentAction<T, TArg1, TArg2, TArg3>)Invokes a chainable method on an object and additional arguments.
T.Chain<TArg1, TArg2, TArg3, TArg4>(TArg1, TArg2, TArg3, TArg4, FluentAction<T, TArg1, TArg2, TArg3, TArg4>)Invokes a chainable method on an object and additional arguments.
T.ForEach<TElement>(IEnumerable<TElement>, FluentAction<T, TElement, int>)Performs a specified action on an object and each element of a sequence, each time taking the result of the action as the object to pass together with the next element, then returns the result of the last action.
T.ForEach<TElement>(IEnumerable<TElement>, FluentAction<T, TElement>)Performs a specified action on an object and each element of a sequence, each time taking the result of the action as the object to pass together with the next element, then returns the result of the last action.
T.ForEach<TElement>(IEnumerable<TElement>, Action<T, TElement, int>)Performs a specified action on an object and each element of a sequence, then returns the object.
T.ForEach<TElement>(IEnumerable<TElement>, Action<T, TElement>)Performs a specified action on an object and each element of a sequence, then returns the object.
T.ForEach<TElement>(ReadOnlySpan<TElement>, FluentAction<T, TElement, int>)Performs a specified action on an object and each element of a span, each time taking the result of the action as the object to pass together with the next element, then returns the result of the last action.
T.ForEach<TElement>(ReadOnlySpan<TElement>, FluentAction<T, TElement>)Performs a specified action on an object and each element of a span, each time taking the result of the action as the object to pass together with the next element, then returns the result of the last action.
T.ForEach<TElement>(ReadOnlySpan<TElement>, Action<T, TElement, int>)Performs a specified action on an object and each element of a span, then returns the object.
T.ForEach<TElement>(ReadOnlySpan<TElement>, Action<T, TElement>)Performs a specified action on an object and each element of a span, then returns the object.
T.If(bool, FluentAction<T>)Invokes an action on an object if a condition is verified, then returns the result of the action.
T.If(bool, Action<T>)Invokes an action on an object if a condition is verified, then returns the same object.
T.IfElse(bool, FluentAction<T>, FluentAction<T>)Invokes one of two actions on an object according to a boolean condition, then returns the result of that action.
T.IfElse(bool, Action<T>, Action<T>)Invokes one of two actions on an object according to a boolean condition, then returns the same object.
T.IfNotNull<T1>(T1?, FluentAction<T, T1>)Invokes an action on an object if a nullable value is not null, then returns the result of the action.
T.IfNotNull<T1>(T1?, Action<T, T1>)Invokes an action on an object if a nullable value is not null, then returns the same object.
T.IfNotNull<T1>(T1?, FluentAction<T, T1>)Invokes an action on an object if a reference is not null, then returns the result of the action.
T.IfNotNull<T1>(T1?, Action<T, T1>)Invokes an action on an object if a reference is not null, then returns the same object.
T.IfNotNullOrEmpty(string?, FluentAction<T, string>)Invokes an action on an object if a string is neither null nor the empty string, then returns the result of the action.
T.IfNotNullOrEmpty(string?, Action<T, string>)Invokes an action on an object if a string is neither null nor the empty string, then returns the same object.
T.Invoke(Action<T>)Invokes an action on an object and returns the same object.
T.Invoke<TArg>(TArg, Action<T, TArg>)Invokes an action on an object and an additional argument and returns the same object.
T.Invoke<TArg1, TArg2>(TArg1, TArg2, Action<T, TArg1, TArg2>)Invokes an action on an object and additional arguments and returns the same object.
T.Invoke<TArg1, TArg2, TArg3>(TArg1, TArg2, TArg3, Action<T, TArg1, TArg2, TArg3>)Invokes an action on an object and additional arguments and returns the same object.
T.Invoke<TArg1, TArg2, TArg3, TArg4>(TArg1, TArg2, TArg3, TArg4, Action<T, TArg1, TArg2, TArg3, TArg4>)Invokes an action on an object and additional arguments and returns the same object.
T.InvokeIf(bool, Action<T>)Invokes an action on an object if a condition is satisfied, then returns the same object.
T.InvokeIf<TArg>(bool, TArg, Action<T, TArg>)Invokes an action on an object and an additional argument if a condition is satisfied, then returns the same object.
T.InvokeIf<TArg1, TArg2>(bool, TArg1, TArg2, Action<T, TArg1, TArg2>)Invokes an action on an object and additional arguments if a condition is satisfied, then returns the same object.
T.InvokeIf<TArg1, TArg2, TArg3>(bool, TArg1, TArg2, TArg3, Action<T, TArg1, TArg2, TArg3>)Invokes an action on an object and additional arguments if a condition is satisfied, then returns the same object.
T.InvokeIf<TArg1, TArg2, TArg3, TArg4>(bool, TArg1, TArg2, TArg3, TArg4, Action<T, TArg1, TArg2, TArg3, TArg4>)Invokes an action on an object and additional arguments if a condition is satisfied, then returns the same object.
T.Switch<TValue>(IEqualityComparer<TValue>, TValue, FluentAction<T>?, (TValue Comparand, FluentAction<T>? Action)[])Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the result of the action.
T.Switch<TValue>(IEqualityComparer<TValue>, TValue, Action<T>?, (TValue Comparand, Action<T>? Action)[])Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the object.
T.Switch<TValue>(IEqualityComparer<TValue>, TValue, (TValue Comparand, FluentAction<T>? Action)[])Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the result of the action.
T.Switch<TValue>(IEqualityComparer<TValue>, TValue, (TValue Comparand, Action<T>? Action)[])Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the object.
T.Switch<TValue>(TValue, FluentAction<T>?, (TValue Comparand, FluentAction<T>? Action)[])Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the result of the action.
T.Switch<TValue>(TValue, Action<T>?, (TValue Comparand, Action<T>? Action)[])Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the object.
T.Switch<TValue>(TValue, (TValue Comparand, FluentAction<T>? Action)[])Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the result of the action.
T.Switch<TValue>(TValue, (TValue Comparand, Action<T>? Action)[])Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the object.

T.Chain overloads

T.Chain(FluentAction<T>)

Invokes a chainable method on an object.

extension<T>(T @this)
{
    public T Chain(FluentAction<T> func)
}
Type parameters
T
The type of the object.
Parameters
this T
The object on which this method was called.
func FluentAction<T>
The chainable method to invoke on this.
Returns

T The reference to this returned by func.

Exceptions
ArgumentNullException
this is null. - or - func is null.

T.Chain<TArg>(TArg, FluentAction<T, TArg>)

Invokes a chainable method on an object and an additional argument.

extension<T>(T @this)
{
    public T Chain<TArg>(TArg arg, FluentAction<T, TArg> func)
}
Type parameters
T
The type of the object.
TArg
The type of the additional parameter to func.
Parameters
this T
The object on which this method was called.
arg TArg
The additional argument to pass to func.
func FluentAction<T, TArg>
The chainable method to invoke on this.
Returns

T The reference to this returned by func.

Exceptions
ArgumentNullException
this is null. - or - func is null.

T.Chain<TArg1, TArg2>(TArg1, TArg2, FluentAction<T, TArg1, TArg2>)

Invokes a chainable method on an object and additional arguments.

extension<T>(T @this)
{
    public T Chain<TArg1, TArg2>(TArg1 arg1, TArg2 arg2, FluentAction<T, TArg1, TArg2> func)
}
Type parameters
T
The type of the object.
TArg1
The type of the first additional parameter to func.
TArg2
The type of the second additional parameter to func.
Parameters
this T
The object on which this method was called.
arg1 TArg1
The first additional argument to pass to func.
arg2 TArg2
The second additional argument to pass to func.
func FluentAction<T, TArg1, TArg2>
The chainable method to invoke on this.
Returns

T The reference to this returned by func.

Exceptions
ArgumentNullException
this is null. - or - func is null.

T.Chain<TArg1, TArg2, TArg3>(TArg1, TArg2, TArg3, FluentAction<T, TArg1, TArg2, TArg3>)

Invokes a chainable method on an object and additional arguments.

extension<T>(T @this)
{
    public T Chain<TArg1, TArg2, TArg3>(TArg1 arg1, TArg2 arg2, TArg3 arg3, FluentAction<T, TArg1, TArg2, TArg3> func)
}
Type parameters
T
The type of the object.
TArg1
The type of the first additional parameter to func.
TArg2
The type of the second additional parameter to func.
TArg3
The type of the third additional parameter to func.
Parameters
this T
The object on which this method was called.
arg1 TArg1
The first additional argument to pass to func.
arg2 TArg2
The second additional argument to pass to func.
arg3 TArg3
The third additional argument to pass to func.
func FluentAction<T, TArg1, TArg2, TArg3>
The chainable method to invoke on this.
Returns

T The reference to this returned by func.

Exceptions
ArgumentNullException
this is null. - or - func is null.

T.Chain<TArg1, TArg2, TArg3, TArg4>(TArg1, TArg2, TArg3, TArg4, FluentAction<T, TArg1, TArg2, TArg3, TArg4>)

Invokes a chainable method on an object and additional arguments.

extension<T>(T @this)
{
    public T Chain<TArg1, TArg2, TArg3, TArg4>(TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, FluentAction<T, TArg1, TArg2, TArg3, TArg4> func)
}
Type parameters
T
The type of the object.
TArg1
The type of the first additional parameter to func.
TArg2
The type of the second additional parameter to func.
TArg3
The type of the third additional parameter to func.
TArg4
The type of the fourth additional parameter to func.
Parameters
this T
The object on which this method was called.
arg1 TArg1
The first additional argument to pass to func.
arg2 TArg2
The second additional argument to pass to func.
arg3 TArg3
The third additional argument to pass to func.
arg4 TArg4
The fourth additional argument to pass to func.
func FluentAction<T, TArg1, TArg2, TArg3, TArg4>
The chainable method to invoke on this.
Returns

T The reference to this returned by func.

Exceptions
ArgumentNullException
this is null. - or - func is null.

T.ForEach overloads

T.ForEach<TElement>(IEnumerable<TElement>, FluentAction<T, TElement, int>)

Performs a specified action on an object and each element of a sequence, each time taking the result of the action as the object to pass together with the next element, then returns the result of the last action.

extension<T>(T @this)
{
    public T ForEach<TElement>(IEnumerable<TElement> sequence, FluentAction<T, TElement, int> action)
}
Type parameters
T
The type of the object.
TElement
The type of each element of the sequence.
Parameters
this T
The object on which this method was called.
sequence IEnumerable<TElement>
The sequence of elements.
action FluentAction<T, TElement, int>
The action to perform.
Returns

T The result of the last call to action.

Exceptions
ArgumentNullException
this is null. - or - action is null. - or - sequence is null.
Remarks

This method is essentially the same as T.ForEach, but it also passes an index to action. The passed index is 0 for the first call and is incremented by 1 for each subsequent call.

See also

T.ForEach<TElement>(IEnumerable<TElement>, FluentAction<T, TElement>)

Performs a specified action on an object and each element of a sequence, each time taking the result of the action as the object to pass together with the next element, then returns the result of the last action.

extension<T>(T @this)
{
    public T ForEach<TElement>(IEnumerable<TElement> sequence, FluentAction<T, TElement> action)
}
Type parameters
T
The type of the object.
TElement
The type of each element of the sequence.
Parameters
this T
The object on which this method was called.
sequence IEnumerable<TElement>
The sequence of elements.
action FluentAction<T, TElement>
The action to perform.
Returns

T The result of the last call to action.

Exceptions
ArgumentNullException
this is null. - or - action is null. - or - sequence is null.
See also

T.ForEach<TElement>(IEnumerable<TElement>, Action<T, TElement, int>)

Performs a specified action on an object and each element of a sequence, then returns the object.

extension<T>(T @this)
{
    public T ForEach<TElement>(IEnumerable<TElement> sequence, Action<T, TElement, int> action)
}
Type parameters
T
The type of the object.
TElement
The type of each element of the sequence.
Parameters
this T
The object on which this method was called.
sequence IEnumerable<TElement>
The sequence of elements.
action Action<T, TElement, int>
The action to perform.
Returns

T A reference to this after the last call to action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null. - or - sequence is null.
Remarks

This method is essentially the same as T.ForEach, but it also passes an index to action. The passed index is 0 for the first call and is incremented by 1 for each subsequent call.

See also

T.ForEach<TElement>(IEnumerable<TElement>, Action<T, TElement>)

Performs a specified action on an object and each element of a sequence, then returns the object.

extension<T>(T @this)
{
    public T ForEach<TElement>(IEnumerable<TElement> sequence, Action<T, TElement> action)
}
Type parameters
T
The type of the object.
TElement
The type of each element of the sequence.
Parameters
this T
The object on which this method was called.
sequence IEnumerable<TElement>
The sequence of elements.
action Action<T, TElement>
The action to perform.
Returns

T A reference to this after the last call to action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null. - or - sequence is null.
See also

T.ForEach<TElement>(ReadOnlySpan<TElement>, FluentAction<T, TElement, int>)

Performs a specified action on an object and each element of a span, each time taking the result of the action as the object to pass together with the next element, then returns the result of the last action.

extension<T>(T @this)
{
    public T ForEach<TElement>(ReadOnlySpan<TElement> span, FluentAction<T, TElement, int> action)
}
Type parameters
T
The type of the object.
TElement
The type of each element of the span.
Parameters
this T
The object on which this method was called.
span ReadOnlySpan<TElement>
The span of elements.
action FluentAction<T, TElement, int>
The action to perform.
Returns

T The result of the last call to action.

Exceptions
ArgumentNullException
this is null. - or - action is null.
Remarks

This method is essentially the same as T.ForEach, but it also passes the index of each element to action.

See also

T.ForEach<TElement>(ReadOnlySpan<TElement>, FluentAction<T, TElement>)

Performs a specified action on an object and each element of a span, each time taking the result of the action as the object to pass together with the next element, then returns the result of the last action.

extension<T>(T @this)
{
    public T ForEach<TElement>(ReadOnlySpan<TElement> span, FluentAction<T, TElement> action)
}
Type parameters
T
The type of the object.
TElement
The type of each element of the span.
Parameters
this T
The object on which this method was called.
span ReadOnlySpan<TElement>
The span of elements.
action FluentAction<T, TElement>
The action to perform.
Returns

T The result of the last call to action.

Exceptions
ArgumentNullException
this is null. - or - action is null.
See also

T.ForEach<TElement>(ReadOnlySpan<TElement>, Action<T, TElement, int>)

Performs a specified action on an object and each element of a span, then returns the object.

extension<T>(T @this)
{
    public T ForEach<TElement>(ReadOnlySpan<TElement> span, Action<T, TElement, int> action)
}
Type parameters
T
The type of the object.
TElement
The type of each element of the span.
Parameters
this T
The object on which this method was called.
span ReadOnlySpan<TElement>
The span of elements.
action Action<T, TElement, int>
The action to perform.
Returns

T A reference to this after the last call to action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.
Remarks

This method is essentially the same as T.ForEach, but it also passes the index of each element to action.

See also

T.ForEach<TElement>(ReadOnlySpan<TElement>, Action<T, TElement>)

Performs a specified action on an object and each element of a span, then returns the object.

extension<T>(T @this)
{
    public T ForEach<TElement>(ReadOnlySpan<TElement> span, Action<T, TElement> action)
}
Type parameters
T
The type of the object.
TElement
The type of each element of the span.
Parameters
this T
The object on which this method was called.
span ReadOnlySpan<TElement>
The span of elements.
action Action<T, TElement>
The action to perform.
Returns

T A reference to this after the last call to action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.
See also

T.If overloads

T.If(bool, FluentAction<T>)

Invokes an action on an object if a condition is verified, then returns the result of the action.

extension<T>(T @this)
{
    public T If(bool condition, FluentAction<T> then)
}
Type parameters
T
The type of the object.
Parameters
this T
The object on which this method was called.
condition bool
The condition to test.
then FluentAction<T>
The action to perform on this if condition is true.
Returns

T The result of then if condition is true; otherwise, a reference to this.

Exceptions
ArgumentNullException
this is null. - or - then is null.
See also

T.If(bool, Action<T>)

Invokes an action on an object if a condition is verified, then returns the same object.

extension<T>(T @this)
{
    public T If(bool condition, Action<T> then)
}
Type parameters
T
The type of the object.
Parameters
this T
The object on which this method was called.
condition bool
The condition to test.
then Action<T>
The action to perform on this if condition is true.
Returns

T A reference to this after then, if called, returns.

Exceptions
ArgumentNullException
this is null. - or - then is null.
See also

T.IfElse overloads

T.IfElse(bool, FluentAction<T>, FluentAction<T>)

Invokes one of two actions on an object according to a boolean condition, then returns the result of that action.

extension<T>(T @this)
{
    public T IfElse(bool condition, FluentAction<T> then, FluentAction<T> @else)
}
Type parameters
T
The type of the object.
Parameters
this T
The object on which this method was called.
condition bool
The condition to test.
then FluentAction<T>
The action to perform on this if condition is true.
else FluentAction<T>
The action to perform on this if condition is false.
Returns

T The result of then if condition is true; otherwise, the result of else.

Exceptions
ArgumentNullException
this is null. - or - then is null. - or - else is null.

T.IfElse(bool, Action<T>, Action<T>)

Invokes one of two actions on an object according to a boolean condition, then returns the same object.

extension<T>(T @this)
{
    public T IfElse(bool condition, Action<T> then, Action<T> @else)
}
Type parameters
T
The type of the object.
Parameters
this T
The object on which this method was called.
condition bool
The condition to test.
then Action<T>
The action to perform on this if condition is true.
else Action<T>
The action to perform on this if condition is false.
Returns

T A reference to this after either then or else returns.

Exceptions
ArgumentNullException
this is null. - or - then is null. - or - else is null.

T.IfNotNull overloads

T.IfNotNull<T1>(T1?, FluentAction<T, T1>)

Invokes an action on an object if a nullable value is not null, then returns the result of the action.

extension<T>(T @this)
{
    public T IfNotNull<T1>(T1? arg, FluentAction<T, T1> then) where T1 : struct
}
Type parameters
T
The type of the object.
T1
The type of the additional argument to pass to then.
Parameters
this T
The object on which this method was called.
arg T1?
The additional argument to pass to then.
then FluentAction<T, T1>
The action to perform on this and arg if arg is not null.
Returns

T The result of then if arg is not null; otherwise, a reference to this.

Exceptions
ArgumentNullException
this is null. - or - then is null.

T.IfNotNull<T1>(T1?, Action<T, T1>)

Invokes an action on an object if a nullable value is not null, then returns the same object.

extension<T>(T @this)
{
    public T IfNotNull<T1>(T1? arg, Action<T, T1> then) where T1 : struct
}
Type parameters
T
The type of the object.
T1
The type of the additional argument to pass to then.
Parameters
this T
The object on which this method was called.
arg T1?
The additional argument to pass to then.
then Action<T, T1>
The action to perform on this and arg if arg is not null.
Returns

T A reference to this after then, if called, returns.

Exceptions
ArgumentNullException
this is null. - or - then is null.

T.IfNotNull<T1>(T1?, FluentAction<T, T1>)

Invokes an action on an object if a reference is not null, then returns the result of the action.

extension<T>(T @this)
{
    public T IfNotNull<T1>(T1? arg, FluentAction<T, T1> then) where T1 : class
}
Type parameters
T
The type of the object.
T1
The type of the additional argument to pass to then.
Parameters
this T
The object on which this method was called.
arg T1?
The additional argument to pass to then.
then FluentAction<T, T1>
The action to perform on this and arg if arg is not null.
Returns

T The result of then if arg is not null; otherwise, a reference to this.

Exceptions
ArgumentNullException
this is null. - or - then is null.

T.IfNotNull<T1>(T1?, Action<T, T1>)

Invokes an action on an object if a reference is not null, then returns the same object.

extension<T>(T @this)
{
    public T IfNotNull<T1>(T1? arg, Action<T, T1> then) where T1 : class
}
Type parameters
T
The type of the object.
T1
The type of the additional argument to pass to then.
Parameters
this T
The object on which this method was called.
arg T1?
The additional argument to pass to then.
then Action<T, T1>
The action to perform on this and arg if arg is not null.
Returns

T A reference to this after then, if called, returns.

Exceptions
ArgumentNullException
this is null. - or - then is null.

T.IfNotNullOrEmpty overloads

T.IfNotNullOrEmpty(string?, FluentAction<T, string>)

Invokes an action on an object if a string is neither null nor the empty string, then returns the result of the action.

extension<T>(T @this)
{
    public T IfNotNullOrEmpty(string? arg, FluentAction<T, string> then)
}
Type parameters
T
The type of the object.
Parameters
this T
The object on which this method was called.
arg string?
The string to check and pass to then if called.
then FluentAction<T, string>
The action to perform on this and arg if arg is neither null nor the empty string.
Returns

T The result of then if arg is neither null nor the empty string; otherwise, a reference to this.

Exceptions
ArgumentNullException
this is null. - or - then is null.

T.IfNotNullOrEmpty(string?, Action<T, string>)

Invokes an action on an object if a string is neither null nor the empty string, then returns the same object.

extension<T>(T @this)
{
    public T IfNotNullOrEmpty(string? arg, Action<T, string> then)
}
Type parameters
T
The type of the object.
Parameters
this T
The object on which this method was called.
arg string?
The string to check and pass to then if called.
then Action<T, string>
The action to perform on this and arg if arg is neither null nor the empty string.
Returns

T A reference to this after then, if called, returns.

Exceptions
ArgumentNullException
this is null. - or - then is null.

T.Invoke overloads

T.Invoke(Action<T>)

Invokes an action on an object and returns the same object.

extension<T>(T @this)
{
    public T Invoke(Action<T> action)
}
Type parameters
T
The type of the object.
Parameters
this T
The object on which this method was called.
action Action<T>
The action to perform on this.
Returns

T A reference to this after action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.

T.Invoke<TArg>(TArg, Action<T, TArg>)

Invokes an action on an object and an additional argument and returns the same object.

extension<T>(T @this)
{
    public T Invoke<TArg>(TArg arg, Action<T, TArg> action)
}
Type parameters
T
The type of the object.
TArg
The type of the additional parameter to action.
Parameters
this T
The object on which this method was called.
arg TArg
The additional argument to pass to action.
action Action<T, TArg>
The action to perform on this and arg.
Returns

T A reference to this after action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.

T.Invoke<TArg1, TArg2>(TArg1, TArg2, Action<T, TArg1, TArg2>)

Invokes an action on an object and additional arguments and returns the same object.

extension<T>(T @this)
{
    public T Invoke<TArg1, TArg2>(TArg1 arg1, TArg2 arg2, Action<T, TArg1, TArg2> action)
}
Type parameters
T
The type of the object.
TArg1
The type of the first additional parameter to action.
TArg2
The type of the second additional parameter to action.
Parameters
this T
The object on which this method was called.
arg1 TArg1
The first additional argument to pass to action.
arg2 TArg2
The second additional argument to pass to action.
action Action<T, TArg1, TArg2>
The action to perform on this and the additional arguments.
Returns

T A reference to this after action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.

T.Invoke<TArg1, TArg2, TArg3>(TArg1, TArg2, TArg3, Action<T, TArg1, TArg2, TArg3>)

Invokes an action on an object and additional arguments and returns the same object.

extension<T>(T @this)
{
    public T Invoke<TArg1, TArg2, TArg3>(TArg1 arg1, TArg2 arg2, TArg3 arg3, Action<T, TArg1, TArg2, TArg3> action)
}
Type parameters
T
The type of the object.
TArg1
The type of the first additional parameter to action.
TArg2
The type of the second additional parameter to action.
TArg3
The type of the third additional parameter to action.
Parameters
this T
The object on which this method was called.
arg1 TArg1
The first additional argument to pass to action.
arg2 TArg2
The second additional argument to pass to action.
arg3 TArg3
The third additional argument to pass to action.
action Action<T, TArg1, TArg2, TArg3>
The action to perform on this and the additional arguments.
Returns

T A reference to this after action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.

T.Invoke<TArg1, TArg2, TArg3, TArg4>(TArg1, TArg2, TArg3, TArg4, Action<T, TArg1, TArg2, TArg3, TArg4>)

Invokes an action on an object and additional arguments and returns the same object.

extension<T>(T @this)
{
    public T Invoke<TArg1, TArg2, TArg3, TArg4>(TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, Action<T, TArg1, TArg2, TArg3, TArg4> action)
}
Type parameters
T
The type of the object.
TArg1
The type of the first additional parameter to action.
TArg2
The type of the second additional parameter to action.
TArg3
The type of the third additional parameter to action.
TArg4
The type of the fourth additional parameter to action.
Parameters
this T
The object on which this method was called.
arg1 TArg1
The first additional argument to pass to action.
arg2 TArg2
The second additional argument to pass to action.
arg3 TArg3
The third additional argument to pass to action.
arg4 TArg4
The fourth additional argument to pass to action.
action Action<T, TArg1, TArg2, TArg3, TArg4>
The action to perform on this and the additional arguments.
Returns

T A reference to this after action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.

T.InvokeIf overloads

T.InvokeIf(bool, Action<T>)

Invokes an action on an object if a condition is satisfied, then returns the same object.

extension<T>(T @this)
{
    public T InvokeIf(bool condition, Action<T> action)
}
Type parameters
T
The type of the object.
Parameters
this T
The object on which this method was called.
condition bool
The condition to check.
action Action<T>
The action to perform on this.
Returns

T A reference to this after action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.

T.InvokeIf<TArg>(bool, TArg, Action<T, TArg>)

Invokes an action on an object and an additional argument if a condition is satisfied, then returns the same object.

extension<T>(T @this)
{
    public T InvokeIf<TArg>(bool condition, TArg arg, Action<T, TArg> action)
}
Type parameters
T
The type of the object.
TArg
The type of the additional parameter to action.
Parameters
this T
The object on which this method was called.
condition bool
The condition to check.
arg TArg
The additional argument to pass to action.
action Action<T, TArg>
The action to perform on this and arg.
Returns

T A reference to this after action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.

T.InvokeIf<TArg1, TArg2>(bool, TArg1, TArg2, Action<T, TArg1, TArg2>)

Invokes an action on an object and additional arguments if a condition is satisfied, then returns the same object.

extension<T>(T @this)
{
    public T InvokeIf<TArg1, TArg2>(bool condition, TArg1 arg1, TArg2 arg2, Action<T, TArg1, TArg2> action)
}
Type parameters
T
The type of the object.
TArg1
The type of the first additional parameter to action.
TArg2
The type of the second additional parameter to action.
Parameters
this T
The object on which this method was called.
condition bool
The condition to check.
arg1 TArg1
The first additional argument to pass to action.
arg2 TArg2
The second additional argument to pass to action.
action Action<T, TArg1, TArg2>
The action to perform on this and the additional arguments.
Returns

T A reference to this after action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.

T.InvokeIf<TArg1, TArg2, TArg3>(bool, TArg1, TArg2, TArg3, Action<T, TArg1, TArg2, TArg3>)

Invokes an action on an object and additional arguments if a condition is satisfied, then returns the same object.

extension<T>(T @this)
{
    public T InvokeIf<TArg1, TArg2, TArg3>(bool condition, TArg1 arg1, TArg2 arg2, TArg3 arg3, Action<T, TArg1, TArg2, TArg3> action)
}
Type parameters
T
The type of the object.
TArg1
The type of the first additional parameter to action.
TArg2
The type of the second additional parameter to action.
TArg3
The type of the third additional parameter to action.
Parameters
this T
The object on which this method was called.
condition bool
The condition to check.
arg1 TArg1
The first additional argument to pass to action.
arg2 TArg2
The second additional argument to pass to action.
arg3 TArg3
The third additional argument to pass to action.
action Action<T, TArg1, TArg2, TArg3>
The action to perform on this and the additional arguments.
Returns

T A reference to this after action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.

T.InvokeIf<TArg1, TArg2, TArg3, TArg4>(bool, TArg1, TArg2, TArg3, TArg4, Action<T, TArg1, TArg2, TArg3, TArg4>)

Invokes an action on an object and additional arguments if a condition is satisfied, then returns the same object.

extension<T>(T @this)
{
    public T InvokeIf<TArg1, TArg2, TArg3, TArg4>(bool condition, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, Action<T, TArg1, TArg2, TArg3, TArg4> action)
}
Type parameters
T
The type of the object.
TArg1
The type of the first additional parameter to action.
TArg2
The type of the second additional parameter to action.
TArg3
The type of the third additional parameter to action.
TArg4
The type of the fourth additional parameter to action.
Parameters
this T
The object on which this method was called.
condition bool
The condition to check.
arg1 TArg1
The first additional argument to pass to action.
arg2 TArg2
The second additional argument to pass to action.
arg3 TArg3
The third additional argument to pass to action.
arg4 TArg4
The fourth additional argument to pass to action.
action Action<T, TArg1, TArg2, TArg3, TArg4>
The action to perform on this and the additional arguments.
Returns

T A reference to this after action returns.

Exceptions
ArgumentNullException
this is null. - or - action is null.

T.Switch overloads

T.Switch<TValue>(IEqualityComparer<TValue>, TValue, FluentAction<T>?, (TValue Comparand, FluentAction<T>? Action)[])

Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the result of the action.

extension<T>(T @this)
{
    public T Switch<TValue>(IEqualityComparer<TValue> comparer, TValue value, FluentAction<T>? @default, params (TValue Comparand, FluentAction<T>? Action)[] cases)
}
Type parameters
T
The type of the object.
TValue
The type of the value being compared.
Parameters
this T
The object on which this method was called.
comparer IEqualityComparer<TValue>
The interface to use for comparisons.
value TValue
The value to compare.
default FluentAction<T>?
An optional action to perform on this if value is not equal to any of the values in cases. If this parameter is null and value is not equal to any of the values in cases, this method returns immediately.
cases (TValue Comparand, FluentAction<T>? Action)[]
An array of pairs, where each element consists of a value to compare against value and an optional action to perform on this if they are equal. If the action is null, no action is performed if the value is equal to value; instead, the method returns immediately.
Returns

T The result of the action of the first case whose comparand is equal to value, or of default if there is no such case, or a reference to this if the action to invoke is null.

Exceptions
ArgumentNullException
this is null. - or - comparer is null. - or - cases is null.

T.Switch<TValue>(IEqualityComparer<TValue>, TValue, Action<T>?, (TValue Comparand, Action<T>? Action)[])

Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the object.

extension<T>(T @this)
{
    public T Switch<TValue>(IEqualityComparer<TValue> comparer, TValue value, Action<T>? @default, params (TValue Comparand, Action<T>? Action)[] cases)
}
Type parameters
T
The type of the object.
TValue
The type of the value being compared.
Parameters
this T
The object on which this method was called.
comparer IEqualityComparer<TValue>
The interface to use for comparisons.
value TValue
The value to compare.
default Action<T>?
An optional action to perform on this if value is not equal to any of the values in cases. If this parameter is null and value is not equal to any of the values in cases, this method returns immediately.
cases (TValue Comparand, Action<T>? Action)[]
An array of pairs, where each element consists of a value to compare against value and an optional action to perform on this if they are equal. If the action is null, no action is performed if the value is equal to value; instead, the method returns immediately.
Returns

T A reference to this after the action to invoke, if any, returns. The action to invoke is the action of the first case whose comparand is equal to value, or default if there is no such case.

Exceptions
ArgumentNullException
this is null. - or - comparer is null. - or - cases is null.

T.Switch<TValue>(IEqualityComparer<TValue>, TValue, (TValue Comparand, FluentAction<T>? Action)[])

Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the result of the action.

extension<T>(T @this)
{
    public T Switch<TValue>(IEqualityComparer<TValue> comparer, TValue value, params (TValue Comparand, FluentAction<T>? Action)[] cases)
}
Type parameters
T
The type of the object.
TValue
The type of the value being compared.
Parameters
this T
The object on which this method was called.
comparer IEqualityComparer<TValue>
The interface to use for comparisons.
value TValue
The value to compare.
cases (TValue Comparand, FluentAction<T>? Action)[]
An array of pairs, where each element consists of a value to compare against value and an optional action to perform on this if they are equal. If the action is null, no action is performed if the value is equal to value; instead, the method returns immediately.
Returns

T The result of the action of the first case whose comparand is equal to value, or a reference to this if there is no such case or its action is null.

Exceptions
ArgumentNullException
this is null. - or - comparer is null. - or - cases is null.
Remarks

If value is not equal to any of the values in cases, this method returns immediately.

T.Switch<TValue>(IEqualityComparer<TValue>, TValue, (TValue Comparand, Action<T>? Action)[])

Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the object.

extension<T>(T @this)
{
    public T Switch<TValue>(IEqualityComparer<TValue> comparer, TValue value, params (TValue Comparand, Action<T>? Action)[] cases)
}
Type parameters
T
The type of the object.
TValue
The type of the value being compared.
Parameters
this T
The object on which this method was called.
comparer IEqualityComparer<TValue>
The interface to use for comparisons.
value TValue
The value to compare.
cases (TValue Comparand, Action<T>? Action)[]
An array of pairs, where each element consists of a value to compare against value and an optional action to perform on this if they are equal. If the action is null, no action is performed if the value is equal to value; instead, the method returns immediately.
Returns

T A reference to this after one of the actions in cases, if any, returns.

Exceptions
ArgumentNullException
this is null. - or - comparer is null. - or - cases is null.
Remarks

If value is not equal to any of the values in cases, this method returns immediately.

T.Switch<TValue>(TValue, FluentAction<T>?, (TValue Comparand, FluentAction<T>? Action)[])

Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the result of the action.

extension<T>(T @this)
{
    public T Switch<TValue>(TValue value, FluentAction<T>? @default, params (TValue Comparand, FluentAction<T>? Action)[] cases)
}
Type parameters
T
The type of the object.
TValue
The type of the value being compared.
Parameters
this T
The object on which this method was called.
value TValue
The value to compare.
default FluentAction<T>?
An optional action to perform on this if value is not equal to any of the values in cases. If this parameter is null and value is not equal to any of the values in cases, this method returns immediately.
cases (TValue Comparand, FluentAction<T>? Action)[]
An array of pairs, where each element consists of a value to compare against value and an optional action to perform on this if they are equal. If the action is null, no action is performed if the value is equal to value; instead, the method returns immediately.
Returns

T The result of the action of the first case whose comparand is equal to value, or of default if there is no such case, or a reference to this if the action to invoke is null.

Exceptions
ArgumentNullException
this is null. - or - cases is null.

T.Switch<TValue>(TValue, Action<T>?, (TValue Comparand, Action<T>? Action)[])

Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the object.

extension<T>(T @this)
{
    public T Switch<TValue>(TValue value, Action<T>? @default, params (TValue Comparand, Action<T>? Action)[] cases)
}
Type parameters
T
The type of the object.
TValue
The type of the value being compared.
Parameters
this T
The object on which this method was called.
value TValue
The value to compare.
default Action<T>?
An optional action to perform on this if value is not equal to any of the values in cases. If this parameter is null and value is not equal to any of the values in cases, this method returns immediately.
cases (TValue Comparand, Action<T>? Action)[]
An array of pairs, where each element consists of a value to compare against value and an optional action to perform on this if they are equal. If the action is null, no action is performed if the value is equal to value; instead, the method returns immediately.
Returns

T A reference to this after the action to invoke, if any, returns. The action to invoke is the action of the first case whose comparand is equal to value, or default if there is no such case.

Exceptions
ArgumentNullException
this is null. - or - cases is null.

T.Switch<TValue>(TValue, (TValue Comparand, FluentAction<T>? Action)[])

Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the result of the action.

extension<T>(T @this)
{
    public T Switch<TValue>(TValue value, params (TValue Comparand, FluentAction<T>? Action)[] cases)
}
Type parameters
T
The type of the object.
TValue
The type of the value being compared.
Parameters
this T
The object on which this method was called.
value TValue
The value to compare.
cases (TValue Comparand, FluentAction<T>? Action)[]
An array of pairs, where each element consists of a value to compare against value and an optional action to perform on this if they are equal. If the action is null, no action is performed if the value is equal to value; instead, the method returns immediately.
Returns

T The result of the action of the first case whose comparand is equal to value, or a reference to this if there is no such case or its action is null.

Exceptions
ArgumentNullException
this is null. - or - cases is null.
Remarks

If value is not equal to any of the values in cases, this method returns immediately.

T.Switch<TValue>(TValue, (TValue Comparand, Action<T>? Action)[])

Selects an action to invoke on an object by comparing a given value against a list of comparands, then returns the object.

extension<T>(T @this)
{
    public T Switch<TValue>(TValue value, params (TValue Comparand, Action<T>? Action)[] cases)
}
Type parameters
T
The type of the object.
TValue
The type of the value being compared.
Parameters
this T
The object on which this method was called.
value TValue
The value to compare.
cases (TValue Comparand, Action<T>? Action)[]
An array of pairs, where each element consists of a value to compare against value and an optional action to perform on this if they are equal. If the action is null, no action is performed if the value is equal to value; instead, the method returns immediately.
Returns

T A reference to this after one of the actions in cases, if any, returns.

Exceptions
ArgumentNullException
this is null. - or - cases is null.
Remarks

If value is not equal to any of the values in cases, this method returns immediately.