RedirectToExistingMethod(IMethod)
Redirects the calls to an existing method.
Declaration
IExistingMethodInterception RedirectToExistingMethod(IMethod method)Parameters
| Type | Name | Description |
|---|---|---|
| IMethod | method | The existing method. |
Returns
| Type | Description |
|---|---|
| IExistingMethodInterception |
Remarks
The method must be static and accessible from the site. It can be generic and can be declared in a generic type. Pass the definition of such a method: its type parameters are resolved for each site.
Each parameter of the method is bound to the first of these values that exists, and a required parameter that remains unbound is an error:
- the value of the property of the same name of the arguments given to WithArgs(object);
- the receiver of the site, when the parameter is the first one and the site has a receiver;
- the argument of the site whose parameter has the same name;
- the caller information that its attribute requests;
- its own default value.
Each type parameter of the method and of its declaring types is bound to the first of these types that exists, and a type parameter that remains unbound is an error:
- the value of the property of the same name of the arguments given to WithArgs(object), which is
a Type, for instance
typeof(Order), or an IType; - the type argument of the type parameter of the same name of the intercepted method and of its declaring types.
The value of each argument must convert implicitly to the parameter type. A ref, out or in parameter must receive
an argument of the site with the same reference kind and an identical type. The return type must be implicitly convertible to the
return type of the intercepted method, and identical when the site is inside a conditional access (?.).
For a method group converted to a delegate or to a function pointer, the method must have exactly the signature of the intercepted method.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentException | The method is a constructed generic method. |