-
Notifications
You must be signed in to change notification settings - Fork 1
ILWriter Delegate
Greg G edited this page Dec 31, 2016
·
1 revision
ILWriter.Delegate
contains 54 overloads. Overloads are classed by pair, with one pair having the following structure:
public ILWriter Delegate<TA, TB, TC>(TA a, TB b, TC c, Action<TA, TB, TC> action);
public ILWriter Delegate<TA, TB, TC, TReturn>(TA a, TB b, TC c, Func<TA, TB, TC, TReturn> func);
All Delegate
methods accept from 0 to 26 arguments, and a delegate. All arguments MUST be constants, as defined by ILWriter.IsConstant<T>()
. string
, char
, null
and all numeric types except decimal
are considered constants.
If you wish to access a parameter or variable by index or name, typed or not, pass Context.Argument
, Context.Variable
or Context.This
as an argument.
If an overload with an Action
parameter is used, the last ret
opcode will be removed, allowing the function to go on.
Adding a null
-check to a method can be done this way:
method.Write().ToStart()
.Delegate(Context.Argument(parameter.Index), parameter.Name, (a, b) =>
{
if (a.Value == null)
throw new ArgumentNullException(b);
});