Open sandboxFocus

Method InterceptMethods

InterceptMethods<TScope>(IQuery<TScope>, Func<IMethodInterceptionBuilder, IMethodInterception>)

Registers the interception of the uses of methods in the declarations selected by a query, described by a delegate.

Declaration
public static void InterceptMethods<TScope>(this IQuery<TScope> query, Func<IMethodInterceptionBuilder, IMethodInterception> build) where TScope : class, IDeclaration
Parameters
Type Name Description
IQuery<TScope> query

A query that selects the scope declarations.

Func<IMethodInterceptionBuilder, IMethodInterception> build

A delegate that describes the interception, as in InterceptMethods<TScope>(IAdviser<TScope>, Func<IMethodInterceptionBuilder, IMethodInterception>). It is invoked once, before this method returns.

Type Parameters
Name Description
TScope
Exceptions
Type Condition
ArgumentNullException

build is null.

ArgumentException

The delegate returned null, or a value that does not describe a complete interception.

InvalidOperationException

The delegate discarded a value that it created, or the project that executes the registration does not reference the Metalama.Extensions.Interceptors package.

InterceptMethods<TScope, TTag>(ITaggedQuery<TScope, TTag>, Func<IMethodInterceptionBuilder, IMethodInterception>)

Registers the interception of the uses of methods in the declarations selected by a tagged query, described by a delegate. The tag of each declaration is available to ForEachSite(Func<IMethodInterceptionSite, IMethodInterception>) through ScopeTag.

Declaration
public static void InterceptMethods<TScope, TTag>(this ITaggedQuery<TScope, TTag> query, Func<IMethodInterceptionBuilder, IMethodInterception> build) where TScope : class, IDeclaration
Parameters
Type Name Description
ITaggedQuery<TScope, TTag> query

A tagged query that selects the scope declarations.

Func<IMethodInterceptionBuilder, IMethodInterception> build

A delegate that describes the interception, as in InterceptMethods<TScope>(IAdviser<TScope>, Func<IMethodInterceptionBuilder, IMethodInterception>). It is invoked once, before this method returns.

Type Parameters
Name Description
TScope
TTag
Exceptions
Type Condition
ArgumentNullException

build is null.

ArgumentException

The delegate returned null, or a value that does not describe a complete interception.

InvalidOperationException

The delegate discarded a value that it created, or the project that executes the registration does not reference the Metalama.Extensions.Interceptors package.