IntroduceEvent(INamedType, string, IntroductionScope, OverrideStrategy, Action<IEventBuilder>?, object?)
Introduces a new event to the target type, or overrides the implementation of an existing one, by specifying an event template.
Declaration
IIntroductionAdviceResult<IEvent> IntroduceEvent(INamedType targetType, string eventTemplate, IntroductionScope scope = IntroductionScope.Default, OverrideStrategy whenExists = OverrideStrategy.Default, Action<IEventBuilder>? buildEvent = null, object? tags = null)
Parameters
Type | Name | Description |
---|---|---|
INamedType | targetType | The type into which the event must be introduced. |
string | eventTemplate | The name of the event in the aspect class that must be used as a template for the introduced event. This event must be annotated with TemplateAttribute. The type of the template event can be any delegate type. The type of the introduced event can be changed dynamically thanks to the IEventBuilder returned by this method. |
IntroductionScope | scope | Determines the scope (e.g. Instance or Static) of the introduced event. The default scope depends on the scope of the template event. If the event is static, the introduced event is static. However, if the template event is non-static, then the introduced event copies of the scope of the target declaration of the aspect. |
OverrideStrategy | whenExists | Determines the implementation strategy when an event of the same name is already declared in the target type. The default strategy is to fail with a compile-time error. |
Action<IEventBuilder> | buildEvent | |
object | tags | An optional opaque object of anonymous type passed to the template event and exposed under the Tags property of the meta API. |
Returns
Type | Description |
---|---|
IIntroductionAdviceResult<IEvent> | An IEventBuilder that allows to change the name and the type of the event. |
See Also
IntroduceEvent(INamedType, string, string, string, string?, IntroductionScope, OverrideStrategy, Action<IEventBuilder>?, object?, object?)
Introduces a new event to the target type, or overrides the implementation of an existing one, by specifying individual template methods for the adder, the remover, and the raiser.
Declaration
IIntroductionAdviceResult<IEvent> IntroduceEvent(INamedType targetType, string eventName, string addTemplate, string removeTemplate, string? raiseTemplate = null, IntroductionScope scope = IntroductionScope.Default, OverrideStrategy whenExists = OverrideStrategy.Default, Action<IEventBuilder>? buildEvent = null, object? args = null, object? tags = null)
Parameters
Type | Name | Description |
---|---|---|
INamedType | targetType | The type into which the event must be introduced. |
string | eventName | The name of the introduced event. |
string | addTemplate | The name of the method of the aspect class whose type and implementation will be used as a template for the adder.
This method must be annotated with TemplateAttribute. The signature of this method must
be |
string | removeTemplate | The name of the method of the aspect class whose type and implementation will be used as a template for the remover.
This method must be annotated with TemplateAttribute. The signature of this method must
be |
string | raiseTemplate | Not implemented. |
IntroductionScope | scope | Determines the scope (e.g. Instance or Static) of the introduced event. The default scope depends on the scope of the template event. If the event is static, the introduced event is static. However, if the template event is non-static, then the introduced event copies of the scope of the target declaration of the aspect. |
OverrideStrategy | whenExists | Determines the implementation strategy when an event of the same name is already declared in the target type. The default strategy is to fail with a compile-time error. |
Action<IEventBuilder> | buildEvent | |
object | args | An object (typically of anonymous type) whose properties map to parameters or type parameters of the template methods. |
object | tags | An optional opaque object of anonymous type passed to the template method and exposed under the Tags property of the meta API. |
Returns
Type | Description |
---|---|
IIntroductionAdviceResult<IEvent> | An IEventBuilder that allows to change the name and the type of the event. |