MetalamaAPI documentationAspect APIMetalama.​Framework.​AdvisingIAdvice­FactoryOverride
Open sandboxFocus

IAdviceFactory.Override Method

Override(IMethod, in MethodTemplateSelector, Object, Object)

Overrides the implementation of a method.

Declaration
IOverrideAdviceResult<IMethod> Override(IMethod targetMethod, in MethodTemplateSelector template, object args = null, object tags = null)
Parameters
Type Name Description
IMethod targetMethod

The method to override.

MethodTemplateSelector template

Name of a method in the aspect class whose implementation will be used as a template. This property must be annotated with TemplateAttribute. To select a different templates according to the kind of target method (such as async or iterator methods), use the constructor of the MethodTemplateSelector type. To specify a single template for all methods, pass a string.

Object args

An object (typically of anonymous type) whose properties map to parameters or type parameters of the template method.

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<IMethod>
See Also

Override(IConstructor, String, Object, Object)

Overrides the implementation of a constructor.

Declaration
IOverrideAdviceResult<IConstructor> Override(IConstructor targetConstructor, string template, object args = null, object tags = null)
Parameters
Type Name Description
IConstructor targetConstructor

The constructor to override.

String template

Name of a method in the aspect class whose implementation will be used as a template. 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 method.

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<IConstructor>

Override(IFieldOrProperty, String, Object)

Overrides a field or property by specifying a property template.

Declaration
IOverrideAdviceResult<IProperty> Override(IFieldOrProperty targetFieldOrProperty, string template, object tags = null)
Parameters
Type Name Description
IFieldOrProperty targetFieldOrProperty

The field or property to override.

String template

The name of a property of the aspect class, with a getter, a setter, or both, whose implementation will be used as a template. This property must be annotated with TemplateAttribute.

Object tags

An optional opaque object of anonymous type passed to the template property and exposed under the Tags property of the meta API.

Returns
Type Description
IOverrideAdviceResult<IProperty>
See Also