Open sandboxFocus

Method WithArgs

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 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

args is null.

ArgumentException

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