SetArgument(IParameter, IExpression)
Sets the value that the call site passes to a parameter that was added to the Method method builder, either by the template or by the delegate.
Declaration
void SetArgument(IParameter parameter, IExpression value)Parameters
| Type | Name | Description |
|---|---|---|
| IParameter | parameter | An added parameter of the Method method builder, which follows the receiver and argument parameters. |
| IExpression | value | The value at this call site. It takes any form that the arguments of RedirectToExistingMethod(IMethod) accept for a parameter, for instance a TypedConstant or a parameter of the calling member given by the Context property. |
Remarks
This method is an alternative to the property of the arguments that has the name of the parameter. Unlike the arguments, which are given once by WithArgs(object), it can use the Context property of the call site. A parameter cannot receive a value from both: the site is then not intercepted and LAMA1014 is reported.
The values are not part of the key that deduplicates the interceptor methods, so the call sites that pass different values share one method.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
SetArgument(IParameter, TypedConstant)
Gives the value of a parameter added to the Method method at this call site, as a constant.
Declaration
void SetArgument(IParameter parameter, TypedConstant value)Parameters
| Type | Name | Description |
|---|---|---|
| IParameter | parameter | An added parameter of the Method method builder. |
| TypedConstant | value | The constant value at this call site. A value of a numeric type, of bool or of char is
converted implicitly to a TypedConstant, for instance in |
Remarks
This method is equivalent to SetArgument(IParameter, IExpression), and exists because C# does not apply a user-defined conversion to an interface type such as IExpression.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|