Open sandboxFocus

Method WithArgs

WithArgs(object)

Sets the arguments that bind parameters and type parameters of the existing method by name.

Declaration
IExistingMethodInterception WithArgs(object args)
Parameters
Type Name Description
object args

An anonymous object, an IReadOnlyDictionary<TKey, TValue> of names and values, or an IObjectReader.

Returns
Type Description
IExistingMethodInterception
Remarks

RedirectToExistingMethod(IMethod) describes how the arguments take precedence over the other values. A property that binds a parameter accepts these values:

A property that binds a type parameter is a Type or an IType. A property that names no parameter and no type parameter is an error. An argument of the site can be passed to two parameters only when it is passed by value and its evaluation has no side effect. For a method group converted to a delegate or to a function pointer, the arguments can bind only type parameters.

Exceptions
Type Condition
ArgumentNullException

args is null.

ArgumentException

A value of args has a type that cannot bind a parameter or a type parameter.