QuickCast to Delegates
this static class contains methods to transform a named method to its respectively delegate Func
or Action
.
It turns way more easily to uses the extensions to Curry
and Partial Application
.
Methods
Name
Parameters
Returns
Description
F
Func<TResult> function
Func<TResult>
Casts a function as a delegate
F
Func<T, TResult> function
Func<T, TResult>
Casts a function as a delegate
F
Func<T, T2, TResult> function
Func<T, T2, TResult>
Casts a function as a delegate
F
Func<T, T2, T3, TResult> function
Func<T, T2, T3, TResult>
Casts a function as a delegate
F
Func<T, T2, TResult> function
Func<T, T2, TResult>
Casts a function as a delegate
A
Action function
Action
Casts a function as a delegate
A
Action<T> function
Action<T>
Casts a function as a delegate
A
Action<T, T2> function
Action<T, T2>
Casts a function as a delegate
A
Action<T, T2, T3> function
Action<T, T2, T3>
Casts a function as a delegate
A
Action<T, T2, T3, T4> function
Action<T, T2, T3, T4>
Casts a function as a delegate
Usage
The several overloads avaliable in this class can be used to cast a named function into its respectively delegate.
Unfortunately, because of the language limitations is not possible (until now) treat an named function directly as an delegate.
See the code bellow:
The attemp to uses Curry
and PartialApply
will causes an compile error, because SampleAdd isa method and can't be used in this specific context.
To uses these extensions is necessary to cast the named function into a delegate.
With this class, is possible to create a more quick version of this cast.
To do this inline cast, you need to follow the steps bellow:
Add a command of
using static Tango.Functional.QuickDelegateCast
;Uses the correct overload described in
Methods
subsection.
Through the F()
and A()
sintax is possible to cast a named function to its respectively delegate and use its extensions.
The fundamentals about Currying and Partial Application can be find in Fundamentals > Currying and Partial Application.
Last updated
Was this helpful?