IntroduceConversionOperator(IAdviser<INamedType>, string, IType, IType, bool, bool, OverrideStrategy, Action<IMethodBuilder>?, object?, object?)
Introduces a conversion operator to the target type, or overrides the implementation of an existing one. Use the With<TNewDeclaration>(TNewDeclaration) method to apply the advice to a different type than the current one.
Declaration
public static IIntroductionAdviceResult<IMethod> IntroduceConversionOperator(this IAdviser<INamedType> adviser, string template, IType fromType, IType toType, bool isImplicit = false, bool isChecked = false, OverrideStrategy whenExists = OverrideStrategy.Default, Action<IMethodBuilder>? buildOperator = null, object? args = null, object? tags = null)Parameters
| Type | Name | Description |
|---|---|---|
| IAdviser<INamedType> | adviser | An adviser for a named type. |
| 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 | fromType | The type to convert from. |
| IType | toType | The type to convert to. |
| bool | isImplicit | Determines whether the conversion is implicit ( |
| bool | isChecked | Determines whether the conversion is checked. The default value is |
| OverrideStrategy | whenExists | Determines the implementation strategy when an operator of the same signature is already declared in the target type. The default strategy is to fail with a compile-time error. |
| Action<IMethodBuilder> | buildOperator | An optional delegate to customize the introduced operator via IMethodBuilder. |
| object | args | An optional object (typically of anonymous type) whose properties map to template method parameters or type parameters. See Sharing state with adviceSharing state with advice for details. |
| object | tags | An optional object (typically of anonymous type) passed to the template and accessible via |
Returns
| Type | Description |
|---|---|
| IIntroductionAdviceResult<IMethod> | An IIntroductionAdviceResult<T> exposing the introduced or overriding IMethod. |