Open sandboxFocus

Method Add

Add(dynamic?)

Generates run-time code that adds a handler, given as run-time C# expression, to the event.

Declaration
dynamic Add(dynamic? handler)
Parameters
Type Name Description
dynamic handler

A C# expression representing the event handler. If the compile-time type of the expression is dynamic, it must be explicitly cast to IExpression.

Returns
Type Description
dynamic

An internal Metalama statement object representing the event handler addition. It should be ignored in user code.

Remarks

By default, the event is accessed on the current object (this), unless the event is static. The base implementation of the event is invoked, i.e. the implementation before the current aspect layer. To change the default values, use the WithOptions(InvokerOptions) method.

Add(IExpression)

Generates run-time code that adds a handler, given as an IExpression, to the event.

Declaration
dynamic Add(IExpression handler)
Parameters
Type Name Description
IExpression handler

A compile-time IExpression representing the event handler.

Returns
Type Description
dynamic

An internal Metalama statement object representing the event handler addition. It should be ignored in user code.

Remarks

By default, the event is accessed on the current object (this), unless the event is static. The base implementation of the event is invoked, i.e. the implementation before the current aspect layer. To change the default values, use the WithOptions(InvokerOptions) method.