Metalama 1.0 / / Metalama Documentation / Aspect API Documentation / Metalama.​Framework.​Aspects / Method­Template­Selector

Class MethodTemplateSelector

Specifies the templates that must be used by the IAdviceFactory.Override(IMethod) advice.

Inheritance
MethodTemplateSelector
Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public sealed class MethodTemplateSelector : ValueType

Constructors

Name Description
MethodTemplateSelector(String, String, String, String, String, String, Boolean, Boolean)

Initializes a new instance of the MethodTemplateSelector struct by specifying the name of the template methods to be applied. The named passed to this constructor must be the name of methods of the current aspect class, and these methods must be annotated with the TemplateAttribute custom attribute. You can define several templates by passing a value to optional parameters. The appropriate template will be automatically selected according to the method to which the advice is applied. If several templates are eligible for a method, the template that is the last in the list of parameters is selected.

Properties

Name Description
AsyncEnumerableTemplate

Gets the name of the template that must be applied to an async iterator method returning the IAsyncEnumerable type. If the UseEnumerableTemplateForAnyEnumerable is set to true, this template will be used for any method that returns the IAsyncEnumerable type, even if it is not implemented as an async or yield-based iterator.

AsyncEnumeratorTemplate

Gets the name of the template that must be applied to an async iterator method returning the IAsyncEnumerable type. If the UseEnumerableTemplateForAnyEnumerable is set to true, this template will be used for any method that returns the IAsyncEnumerable type, even if it is not implemented as an async or yield-based iterator.

AsyncTemplate

Gets the name of the template that must be applied to async methods, including async iterators (unless AsyncEnumerableTemplate or AsyncEnumeratorTemplate is defined). If UseAsyncTemplateForAnyAwaitable is set to true, this template will be used for any method that has an awaitable return type, including IAsyncEnumerable and IAsyncEnumerator.

DefaultTemplate

Gets the name of the template that must be applied if no other template is applicable. This property is required.

EnumerableTemplate

Gets the name of the template that must be applied to yield-based iterator methods returning an IEnumerable<T> or IEnumerable. If the UseEnumerableTemplateForAnyEnumerable is set to true, this template will be used for any method that returns the IEnumerable<T> or IEnumerable type, even if it not a yield-based iterator.

EnumeratorTemplate

Gets the name of the template that must be applied to yield-based iterator methods returning an IEnumerator<T> or IEnumerator. If the UseEnumerableTemplateForAnyEnumerable is set to true, this template will be used for any method that returns the IEnumerator<T> or IEnumerator type, even if it not a yield-based iterator.

UseAsyncTemplateForAnyAwaitable

Gets a value indicating whether the AsyncTemplate must be applied to all methods returning an awaitable type (including IAsyncEnumerable and IAsyncEnumerator) instead of only to methods that have the async modifier. If the implementation of the template method is async, the awaitable type must also have an async method builder, otherwise the method will be processed by DefaultTemplate.

UseEnumerableTemplateForAnyEnumerable

Gets a value indicating whether the EnumerableTemplate, EnumeratorTemplate, AsyncEnumerableTemplate, AsyncEnumeratorTemplate must be applied to all methods returning a compatible return type (if set to true), instead of only to methods using the yield statement.

Operators

Name Description
Implicit(String to MethodTemplateSelector)

Converts a String to a new instance of the MethodTemplateSelector where the DefaultTemplate property is set to this string.

Extension Methods

PresentingExtensions.AsHyperlink(Object)