Open sandboxFocus

Method OverrideAccessors

OverrideAccessors(IFieldOrPropertyOrIndexer, in GetterTemplateSelector, string?, object?, object?)

Overrides a field or property by specifying a method template for the getter, the setter, or both.

Declaration
IOverrideAdviceResult<IPropertyOrIndexer> OverrideAccessors(IFieldOrPropertyOrIndexer targetFieldOrPropertyOrIndexer, in GetterTemplateSelector getTemplate = default, string? setTemplate = null, object? args = null, object? tags = null)
Parameters
Type Name Description
IFieldOrPropertyOrIndexer targetFieldOrPropertyOrIndexer

The field or property to override.

GetterTemplateSelector getTemplate

The name of the method of the aspect class whose implementation will be used as a template for the getter, or null if the getter should not be overridden. This method must be annotated with TemplateAttribute. The signature of this method must be T Get() where T is either dynamic or a type compatible with the type of the field or property. To select a different templates for iterator getters, use the constructor of the GetterTemplateSelector type. To specify a single template for all properties, pass a string.

string setTemplate

The name of the method of the aspect class whose implementation will be used as a template for the getter, or null if the getter should not be overridden. This method must be annotated with TemplateAttribute. The signature of this method must be void Set(T value) where T is either dynamic or a type compatible with the type of the field or property.

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
IOverrideAdviceResult<IPropertyOrIndexer>
See Also

OverrideAccessors(IFieldOrProperty, in GetterTemplateSelector, string?, object?, object?)

Overrides a field or property by specifying method templates for the getter, the setter, or both.

Declaration
IOverrideAdviceResult<IProperty> OverrideAccessors(IFieldOrProperty targetFieldOrProperty, in GetterTemplateSelector getTemplate = default, string? setTemplate = null, object? args = null, object? tags = null)
Parameters
Type Name Description
IFieldOrProperty targetFieldOrProperty

The field or property to override.

GetterTemplateSelector getTemplate

The name of the method of the aspect class whose implementation will be used as a template for the getter, or null if the getter should not be overridden. This method must be annotated with TemplateAttribute. To select different templates for iterator getters, use the constructor of the GetterTemplateSelector type.

string setTemplate

The name of the method of the aspect class whose implementation will be used as a template for the setter, or null if the setter should not be overridden. This method must be annotated with TemplateAttribute.

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
IOverrideAdviceResult<IProperty>

An IOverrideAdviceResult<T> representing the result of the advice.

See Also

OverrideAccessors(IIndexer, in GetterTemplateSelector, string?, object?, object?)

Overrides an indexer by specifying method templates for the getter, the setter, or both.

Declaration
IOverrideAdviceResult<IIndexer> OverrideAccessors(IIndexer targetIndexer, in GetterTemplateSelector getTemplate = default, string? setTemplate = null, object? args = null, object? tags = null)
Parameters
Type Name Description
IIndexer targetIndexer

The indexer to override.

GetterTemplateSelector getTemplate

The name of the method of the aspect class whose implementation will be used as a template for the getter, or null if the getter should not be overridden. This method must be annotated with TemplateAttribute. To select different templates for iterator getters, use the constructor of the GetterTemplateSelector type.

string setTemplate

The name of the method of the aspect class whose implementation will be used as a template for the setter, or null if the setter should not be overridden. This method must be annotated with TemplateAttribute.

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
IOverrideAdviceResult<IIndexer>

An IOverrideAdviceResult<T> representing the result of the advice.

See Also

OverrideAccessors(IEvent, string?, string?, string?, string?, object?, object?)

Overrides an event by specifying a template for the adder, the remover, and/or the raiser.

Declaration
IOverrideAdviceResult<IEvent> OverrideAccessors(IEvent targetEvent, string? addTemplate = null, string? removeTemplate = null, string? invokeTemplate = null, string? raiseTemplate = null, object? args = null, object? tags = null)
Parameters
Type Name Description
IEvent targetEvent

The event to be overridden.

string addTemplate

The name of the method of the aspect class whose type and implementation will be used as a template for the adder, or null the adder should not be overridden. This method must be annotated with TemplateAttribute. The signature of this method must be void Add(T value) where T is either dynamic or a type compatible with the type of the event.

string removeTemplate

The name of the method of the aspect class whose type and implementation will be used as a template for the remover, or null the adder should not be overridden. This method must be annotated with TemplateAttribute. The signature of this method must be void Remove(T value) where T is either dynamic or a type compatible with the type of the event.

string invokeTemplate

The name of the method of the aspect class whose type and implementation will be used as a template for intercepting invocation of event's handlers. The signature of this method must be T Invoke(), T Invoke(U handler), or T Invoke(U handler, V1 param1, V2 param2, ...)
where T is either dynamic or a type compatible with the return value of the event's delegate type, U is either dynamic or the event's delegate type, Vn are types matching the delegate's parameters.

string raiseTemplate

Not yet implemented.

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
IOverrideAdviceResult<IEvent>
See Also