Open sandboxFocus

Property This

This

Gets a dynamic object that represents the current instance (this) of the object being advised. It can be used as a value (e.g. as a method argument) or can be used to get access to instance members of the instance (e.g. meta.This.MyMethod()).

Declaration
public static dynamic This { get; }
Property Value
Type Description
dynamic
Remarks

The This property exposes the state of the target type as it is after the application of all aspects. If the member is virtual, a virtual call is performed, therefore the implementation on the child type (possibly with all applied aspects) is performed. It corresponds to InvokerOptions.Final.

To access the prior layer (or the base type, if there is no prior layer), use Base. To access static members, use ThisType.

Because This returns a dynamic value, you can access any instance member through it (e.g., meta.This._logger.WriteLine()), and the actual member access will be validated and resolved when the template is expanded in the context of a specific target declaration, not when the template is compiled.

See Also