Metalama 1.0 / / Metalama Documentation / Aspect API / Metalama.​Framework.​Advising / IAdvice­Factory / Override

Method Override

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