Arguments - Testura/Testura.Code GitHub Wiki

Arguments

  • ValueArgument
  • VariableArgument
  • InvocationArgument
  • ReferenceArgument
  • ClassInitializationArgument
  • ArrayInitializationArgument
  • DictionaryInitializationArgument
  • TypeOfArgument
  • ParenthesizedLambdaArgument
  • BinaryExpressionArgument

ValueArgument

Usage

Statement.Expression.Invoke("Method", new List<IArgument> { new ValueArgument(1) });

Result

Method(1);

VariableArgument

Usage

Statement.Expression.Invoke("Method", new List<IArgument> { new VariableArgument("myVariable") });

Result

Method(myVariable);

InvocationArgument

Usage

Statement.Expression.Invoke("Method", new List<IArgument> { new InvocationArgument(new MethodReference("Do")) });

Result

Method(Do());

ReferenceArgument

Usage

Statement.Expression.Invoke("Method", new List<IArgument> { new ReferenceArgument(new VariableReference("i", new MemberReference("MyProperty"))) });

Result

Method(i.MyProperty);

ClassInitializationArgument

Usage

Statement.Expression.Invoke("Method", new List<IArgument> { new ClassInitializationArgument(typeof(List<int>))) });

Result

Method(new List<int>());

ArrayInitializationArgument

Usage

Statement.Expression.Invoke("Method", new List<IArgument> { new ArrayInitializationArgument(typeof(int), new List<IArgument>() { new ValueArgument(1), new ValueArgument(2)}) });

Result

Method(new int[] {1, 2});

DictionaryInitializationArgument

Usage

Statement.Expression.Invoke("Method", new List<IArgument> { new DictionaryInitializationArgument<int, int>(new Dictionary<int, IArgument>() { [1] = new ValueArgument(2)})});

Result

Method(new Dictionary<int,int>{ [1] = 2});

TypeOfArgument

Usage

Statement.Expression.Invoke("Method", new List<IArgument> { new TypeOfArgument(typeof(int))});

Result

Method(typeof(int));

ParenthesizedLambdaArgument

Usage

Statement.Expression.Invoke("Method", new List<IArgument> { new ParenthesizedLambdaArgument(Statement.Expression.Invoke(new MethodReference("Do").AsExpression())});

Result

Method(() => Do());

BinaryExpressionArgument`

Usage

Statement.Expression.Invoke("Method", new List<IArgument> { new BinaryExpressionArgument(new MathBinaryExpression(new ConstantReference(1), new ConstantReference(2), MathOperators.Add ))});

Result

Method(1+2);
⚠️ **GitHub.com Fallback** ⚠️