IntroduceUnaryOperator(IInterfaceImplementationAdviser, string, IType, IType, OperatorKind, OverrideStrategy, Action<IMethodBuilder>?, object?, object?)
Introduces a unary operator to the target type, or overrides the implementation of an existing one. Use the With<TNewDeclaration>(TNewDeclaration) method to apply the advice to another declaration than the current one.
Declaration
public static IIntroductionAdviceResult<IMethod> IntroduceUnaryOperator(this IInterfaceImplementationAdviser adviser, string template, IType inputType, IType resultType, OperatorKind kind, OverrideStrategy whenExists = OverrideStrategy.Default, Action<IMethodBuilder>? buildOperator = null, object? args = null, object? tags = null)Parameters
| Type | Name | Description |
|---|---|---|
| IInterfaceImplementationAdviser | adviser | |
| string | template | Name of the method of the aspect class that will be used as a template for the introduced operator. This method must be annotated with TemplateAttribute. |
| IType | inputType | The type of the input parameter of the operator. |
| IType | resultType | The return type of the operator. |
| OperatorKind | kind | The kind of operator to introduce. |
| OverrideStrategy | whenExists | Determines the implementation strategy when an operator of the same kind and signature is already declared in the target type. The default strategy is to fail with a compile-time error. |
| Action<IMethodBuilder> | buildOperator | An optional callback that allows you to configure the introduced operator method, such as adding custom attributes. |
| 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 |
|---|---|
| IIntroductionAdviceResult<IMethod> | An IIntroductionAdviceResult<T> where the Declaration property exposes the introduced or overridden unary operator. |