MetalamaAPI documentationAspect APIMetalama.​Framework.​AdvisingGetter­Template­SelectorGetter­Template­Selector
Open sandboxFocus

GetterTemplateSelector Constructor

GetterTemplateSelector(String, String, String, Boolean)

Initializes a new instance of the GetterTemplateSelector 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.

public GetterTemplateSelector(string defaultTemplate, string enumerableTemplate = null, string enumeratorTemplate = null, bool useEnumerableTemplateForAnyEnumerable = false)
Type Name Description
System.String defaultTemplate

Name of the template that must be applied if no other template is applicable. This parameter is required.

System.String enumerableTemplate

Name of the template that must be applied to iterator methods returning an System.Collections.Generic.IEnumerable<> or System.Collections.IEnumerable. See EnumerableTemplate for details.

System.String enumeratorTemplate

Name of the template that must be applied to an iterator method returning an an System.Collections.Generic.IEnumerator<> or System.Collections.IEnumerator. See EnumeratorTemplate for details.

System.Boolean useEnumerableTemplateForAnyEnumerable

Indicates whether the EnumerableTemplate or EnumeratorTemplate must be applied to all methods returning compatible return type (if set to true), instead of only to methods using the yield statement. See UseEnumerableTemplateForAnyEnumerable for details.


Note that this type has also an implicit conversion from System.String. If you only want to specify a default template, you can pass a string, without calling the constructor.