FluentExtensions Class
Provides generic extension methods to perform simple operations with fluent syntax.
public static class FluentExtensionsMethods
| Name | Description |
|---|---|
| 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
thisT- The object on which this method was called.
funcFluentAction<T>- The chainable method to invoke on
this.
Returns
T The reference to this returned by func.
Exceptions
ArgumentNullExceptionthisisnull. - or -funcisnull.
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
thisT- The object on which this method was called.
argTArg- The additional argument to pass to
func. funcFluentAction<T, TArg>- The chainable method to invoke on
this.
Returns
T The reference to this returned by func.
Exceptions
ArgumentNullExceptionthisisnull. - or -funcisnull.
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
thisT- The object on which this method was called.
arg1TArg1- The first additional argument to pass to
func. arg2TArg2- The second additional argument to pass to
func. funcFluentAction<T, TArg1, TArg2>- The chainable method to invoke on
this.
Returns
T The reference to this returned by func.
Exceptions
ArgumentNullExceptionthisisnull. - or -funcisnull.
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
thisT- The object on which this method was called.
arg1TArg1- The first additional argument to pass to
func. arg2TArg2- The second additional argument to pass to
func. arg3TArg3- The third additional argument to pass to
func. funcFluentAction<T, TArg1, TArg2, TArg3>- The chainable method to invoke on
this.
Returns
T The reference to this returned by func.
Exceptions
ArgumentNullExceptionthisisnull. - or -funcisnull.
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
thisT- The object on which this method was called.
arg1TArg1- The first additional argument to pass to
func. arg2TArg2- The second additional argument to pass to
func. arg3TArg3- The third additional argument to pass to
func. arg4TArg4- The fourth additional argument to pass to
func. funcFluentAction<T, TArg1, TArg2, TArg3, TArg4>- The chainable method to invoke on
this.
Returns
T The reference to this returned by func.
Exceptions
ArgumentNullExceptionthisisnull. - or -funcisnull.
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
thisT- The object on which this method was called.
sequenceIEnumerable<TElement>- The sequence of elements.
actionFluentAction<T, TElement, int>- The action to perform.
Returns
T The result of the last call to action.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull. - or -sequenceisnull.
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
thisT- The object on which this method was called.
sequenceIEnumerable<TElement>- The sequence of elements.
actionFluentAction<T, TElement>- The action to perform.
Returns
T The result of the last call to action.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull. - or -sequenceisnull.
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
thisT- The object on which this method was called.
sequenceIEnumerable<TElement>- The sequence of elements.
actionAction<T, TElement, int>- The action to perform.
Returns
T A reference to this after the last call to action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull. - or -sequenceisnull.
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
thisT- The object on which this method was called.
sequenceIEnumerable<TElement>- The sequence of elements.
actionAction<T, TElement>- The action to perform.
Returns
T A reference to this after the last call to action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull. - or -sequenceisnull.
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
thisT- The object on which this method was called.
spanReadOnlySpan<TElement>- The span of elements.
actionFluentAction<T, TElement, int>- The action to perform.
Returns
T The result of the last call to action.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
spanReadOnlySpan<TElement>- The span of elements.
actionFluentAction<T, TElement>- The action to perform.
Returns
T The result of the last call to action.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
spanReadOnlySpan<TElement>- The span of elements.
actionAction<T, TElement, int>- The action to perform.
Returns
T A reference to this after the last call to action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
spanReadOnlySpan<TElement>- The span of elements.
actionAction<T, TElement>- The action to perform.
Returns
T A reference to this after the last call to action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
conditionbool- The condition to test.
thenFluentAction<T>- The action to perform on
thisifconditionistrue.
Returns
T The result of then if condition is true; otherwise, a reference to this.
Exceptions
ArgumentNullExceptionthisisnull. - or -thenisnull.
See also
T.If(bool, Action<T>)
Invokes an action on an object if a condition is verified, then returns the same object.
Type parameters
T- The type of the object.
Parameters
thisT- The object on which this method was called.
conditionbool- The condition to test.
thenAction<T>- The action to perform on
thisifconditionistrue.
Returns
T A reference to this after then, if called, returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -thenisnull.
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
thisT- The object on which this method was called.
conditionbool- The condition to test.
thenFluentAction<T>- The action to perform on
thisifconditionistrue. elseFluentAction<T>- The action to perform on
thisifconditionisfalse.
Returns
T The result of then if condition is true; otherwise, the result of else.
Exceptions
ArgumentNullExceptionthisisnull. - or -thenisnull. - or -elseisnull.
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.
Type parameters
T- The type of the object.
Parameters
thisT- The object on which this method was called.
conditionbool- The condition to test.
thenAction<T>- The action to perform on
thisifconditionistrue. elseAction<T>- The action to perform on
thisifconditionisfalse.
Returns
T A reference to this after either then or else returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -thenisnull. - or -elseisnull.
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
thisT- The object on which this method was called.
argT1?- The additional argument to pass to
then. thenFluentAction<T, T1>- The action to perform on
thisandargifargis notnull.
Returns
T The result of then if arg is not null; otherwise, a reference to this.
Exceptions
ArgumentNullExceptionthisisnull. - or -thenisnull.
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
thisT- The object on which this method was called.
argT1?- The additional argument to pass to
then. thenAction<T, T1>- The action to perform on
thisandargifargis notnull.
Returns
T A reference to this after then, if called, returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -thenisnull.
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
thisT- The object on which this method was called.
argT1?- The additional argument to pass to
then. thenFluentAction<T, T1>- The action to perform on
thisandargifargis notnull.
Returns
T The result of then if arg is not null; otherwise, a reference to this.
Exceptions
ArgumentNullExceptionthisisnull. - or -thenisnull.
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
thisT- The object on which this method was called.
argT1?- The additional argument to pass to
then. thenAction<T, T1>- The action to perform on
thisandargifargis notnull.
Returns
T A reference to this after then, if called, returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -thenisnull.
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
thisT- The object on which this method was called.
argstring?- The string to check and pass to
thenif called. thenFluentAction<T, string>- The action to perform on
thisandargifargis neithernullnor the empty string.
Returns
T The result of then if arg is neither null nor the empty string; otherwise, a reference to this.
Exceptions
ArgumentNullExceptionthisisnull. - or -thenisnull.
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.
Type parameters
T- The type of the object.
Parameters
thisT- The object on which this method was called.
argstring?- The string to check and pass to
thenif called. thenAction<T, string>- The action to perform on
thisandargifargis neithernullnor the empty string.
Returns
T A reference to this after then, if called, returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -thenisnull.
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
thisT- The object on which this method was called.
actionAction<T>- The action to perform on
this.
Returns
T A reference to this after action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
argTArg- The additional argument to pass to
action. actionAction<T, TArg>- The action to perform on
thisandarg.
Returns
T A reference to this after action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
arg1TArg1- The first additional argument to pass to
action. arg2TArg2- The second additional argument to pass to
action. actionAction<T, TArg1, TArg2>- The action to perform on
thisand the additional arguments.
Returns
T A reference to this after action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
arg1TArg1- The first additional argument to pass to
action. arg2TArg2- The second additional argument to pass to
action. arg3TArg3- The third additional argument to pass to
action. actionAction<T, TArg1, TArg2, TArg3>- The action to perform on
thisand the additional arguments.
Returns
T A reference to this after action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
arg1TArg1- The first additional argument to pass to
action. arg2TArg2- The second additional argument to pass to
action. arg3TArg3- The third additional argument to pass to
action. arg4TArg4- The fourth additional argument to pass to
action. actionAction<T, TArg1, TArg2, TArg3, TArg4>- The action to perform on
thisand the additional arguments.
Returns
T A reference to this after action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
T.InvokeIf overloads
T.InvokeIf(bool, Action<T>)
Invokes an action on an object if a condition is satisfied, then returns the same object.
Type parameters
T- The type of the object.
Parameters
thisT- The object on which this method was called.
conditionbool- The condition to check.
actionAction<T>- The action to perform on
this.
Returns
T A reference to this after action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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.
Type parameters
T- The type of the object.
TArg- The type of the additional parameter to
action.
Parameters
thisT- The object on which this method was called.
conditionbool- The condition to check.
argTArg- The additional argument to pass to
action. actionAction<T, TArg>- The action to perform on
thisandarg.
Returns
T A reference to this after action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
conditionbool- The condition to check.
arg1TArg1- The first additional argument to pass to
action. arg2TArg2- The second additional argument to pass to
action. actionAction<T, TArg1, TArg2>- The action to perform on
thisand the additional arguments.
Returns
T A reference to this after action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
conditionbool- The condition to check.
arg1TArg1- The first additional argument to pass to
action. arg2TArg2- The second additional argument to pass to
action. arg3TArg3- The third additional argument to pass to
action. actionAction<T, TArg1, TArg2, TArg3>- The action to perform on
thisand the additional arguments.
Returns
T A reference to this after action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
conditionbool- The condition to check.
arg1TArg1- The first additional argument to pass to
action. arg2TArg2- The second additional argument to pass to
action. arg3TArg3- The third additional argument to pass to
action. arg4TArg4- The fourth additional argument to pass to
action. actionAction<T, TArg1, TArg2, TArg3, TArg4>- The action to perform on
thisand the additional arguments.
Returns
T A reference to this after action returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -actionisnull.
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
thisT- The object on which this method was called.
comparerIEqualityComparer<TValue>- The interface to use for comparisons.
valueTValue- The value to compare.
defaultFluentAction<T>?- An optional action to perform on
thisifvalueis not equal to any of the values incases. If this parameter isnullandvalueis not equal to any of the values incases, this method returns immediately. cases(TValue Comparand, FluentAction<T>? Action)[]- An array of pairs, where each element consists of a value to compare against
valueand an optional action to perform onthisif they are equal. If the action isnull, no action is performed if the value is equal tovalue; 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
ArgumentNullExceptionthisisnull. - or -comparerisnull. - or -casesisnull.
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
thisT- The object on which this method was called.
comparerIEqualityComparer<TValue>- The interface to use for comparisons.
valueTValue- The value to compare.
defaultAction<T>?- An optional action to perform on
thisifvalueis not equal to any of the values incases. If this parameter isnullandvalueis not equal to any of the values incases, this method returns immediately. cases(TValue Comparand, Action<T>? Action)[]- An array of pairs, where each element consists of a value to compare against
valueand an optional action to perform onthisif they are equal. If the action isnull, no action is performed if the value is equal tovalue; 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
ArgumentNullExceptionthisisnull. - or -comparerisnull. - or -casesisnull.
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
thisT- The object on which this method was called.
comparerIEqualityComparer<TValue>- The interface to use for comparisons.
valueTValue- The value to compare.
cases(TValue Comparand, FluentAction<T>? Action)[]- An array of pairs, where each element consists of a value to compare against
valueand an optional action to perform onthisif they are equal. If the action isnull, no action is performed if the value is equal tovalue; 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
ArgumentNullExceptionthisisnull. - or -comparerisnull. - or -casesisnull.
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
thisT- The object on which this method was called.
comparerIEqualityComparer<TValue>- The interface to use for comparisons.
valueTValue- The value to compare.
cases(TValue Comparand, Action<T>? Action)[]- An array of pairs, where each element consists of a value to compare against
valueand an optional action to perform onthisif they are equal. If the action isnull, no action is performed if the value is equal tovalue; instead, the method returns immediately.
Returns
T A reference to this after one of the actions in cases, if any, returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -comparerisnull. - or -casesisnull.
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
thisT- The object on which this method was called.
valueTValue- The value to compare.
defaultFluentAction<T>?- An optional action to perform on
thisifvalueis not equal to any of the values incases. If this parameter isnullandvalueis not equal to any of the values incases, this method returns immediately. cases(TValue Comparand, FluentAction<T>? Action)[]- An array of pairs, where each element consists of a value to compare against
valueand an optional action to perform onthisif they are equal. If the action isnull, no action is performed if the value is equal tovalue; 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
ArgumentNullExceptionthisisnull. - or -casesisnull.
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
thisT- The object on which this method was called.
valueTValue- The value to compare.
defaultAction<T>?- An optional action to perform on
thisifvalueis not equal to any of the values incases. If this parameter isnullandvalueis not equal to any of the values incases, this method returns immediately. cases(TValue Comparand, Action<T>? Action)[]- An array of pairs, where each element consists of a value to compare against
valueand an optional action to perform onthisif they are equal. If the action isnull, no action is performed if the value is equal tovalue; 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
ArgumentNullExceptionthisisnull. - or -casesisnull.
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
thisT- The object on which this method was called.
valueTValue- The value to compare.
cases(TValue Comparand, FluentAction<T>? Action)[]- An array of pairs, where each element consists of a value to compare against
valueand an optional action to perform onthisif they are equal. If the action isnull, no action is performed if the value is equal tovalue; 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
ArgumentNullExceptionthisisnull. - or -casesisnull.
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
thisT- The object on which this method was called.
valueTValue- The value to compare.
cases(TValue Comparand, Action<T>? Action)[]- An array of pairs, where each element consists of a value to compare against
valueand an optional action to perform onthisif they are equal. If the action isnull, no action is performed if the value is equal tovalue; instead, the method returns immediately.
Returns
T A reference to this after one of the actions in cases, if any, returns.
Exceptions
ArgumentNullExceptionthisisnull. - or -casesisnull.
Remarks
If value is not equal to any of the values in cases, this method returns immediately.