WithArgs(object)
Sets the arguments that bind parameters and type parameters of the existing method by name.
Declaration
IExistingMethodRegistration WithArgs(object args)Parameters
| Type | Name | Description |
|---|---|---|
| object | args | An anonymous object, an IReadOnlyDictionary<TKey, TValue> of names and values, or an IObjectReader. Its values must be durable. |
Returns
| Type | Description |
|---|---|
| IExistingMethodRegistration |
Remarks
RedirectToExistingMethod(IMethod) describes how the arguments take precedence over the other values. A property that binds a parameter accepts these values:
- a literal:
null, a Boolean, a character, a number, a string or an enumeration value of a run-time-or-compile-time enumeration type; - a Type, which is written as
typeof; - an IDurableExpression, which is emitted at the site. It is created by ToDurable(IExpression) from an IExpression, for instance from a TypedConstant;
- an IDurableRef<T> of a field or a property, which is emitted at the site as an access to that member. It is created by ToDurableRef<T>(T).
A property that binds a type parameter is a Type or an IDurableRef<T> of an IType. A property that names no parameter and no type parameter is an error.
The expressions of a call site, such as its arguments and its receiver, are available only in the delegate given to ForEachSite(Func<IMethodInterceptionSite, IMethodInterception>). Use WithArgs(object) there to pass them.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentException | A value of |