Open sandboxFocus

Method IntroduceDelegate

IntroduceDelegate(INamespaceOrNamedType, string, Action<IDelegateBuilder>, OverrideStrategy)

Introduces a new delegate to the target namespace or type.

Declaration
IIntroductionAdviceResult<INamedType> IntroduceDelegate(INamespaceOrNamedType targetNamespaceOrType, string name, Action<IDelegateBuilder> buildDelegate, OverrideStrategy whenExists = OverrideStrategy.Default)
Parameters
Type Name Description
INamespaceOrNamedType targetNamespaceOrType

The namespace or type into which the delegate must be introduced.

string name

The name of the introduced delegate.

Action<IDelegateBuilder> buildDelegate

A callback that configures the introduced delegate, which means its accessibility, its custom attributes, its type parameters and its signature. The parameter is required and precedes whenExists, because a delegate is defined by its signature and the callback is the only way to give it one.

OverrideStrategy whenExists

Determines the implementation strategy when a type of the same name is already declared in the target namespace or type. The default strategy is to fail with a compile-time error.

Returns
Type Description
IIntroductionAdviceResult<INamedType>

An IIntroductionAdviceResult<T> representing the result of the advice. The Declaration property provides access to the introduced delegate. Unlike the result of introducing a class, this result must not be used to introduce members, because a delegate accepts none.