Machinations

Properties | List of all members
MacroAttribute Class Reference

Allows specifying a macro for a parameter of a source template. More...

Inheritance diagram for MacroAttribute:

## Properties

string | Expression`[get, set]`
| Allows specifying a macro that will be executed for a source template parameter when the template is expanded. More...
int | Editable`[get, set]`
| Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. More...
string | Target`[get, set]`
| Identifies the target parameter of a source template if the MacroAttribute is applied on a template method. More...

## Detailed Description

Allows specifying a macro for a parameter of a source template.

You can apply the attribute on the whole method or on any of its additional parameters. The macro expression is defined in the MacroAttribute.Expression property. When applied on a method, the target template parameter is defined in the MacroAttribute.Target property. To apply the macro silently for the parameter, set the MacroAttribute.Editable property value = -1.

Applying the attribute on a source template method:

[SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
public static void forEach<T>(this IEnumerable<T> collection) {
foreach (var item in collection) {
//$ $END$
}
}

Applying the attribute on a template method parameter:

[SourceTemplate]
public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
/*$ var $x$Id = "$newguid$" + x.ToString();
x.DoSomething($x$Id); */
}

## Property Documentation

## ◆ Editable

int MacroAttribute.Editable

get set

Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.

If the target parameter is used several times in the template, only one occurrence becomes editable; other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, use values >= 0. To make the parameter non-editable when the template is expanded, use -1.

>

## ◆ Expression

string MacroAttribute.Expression

get set

Allows specifying a macro that will be executed for a source template parameter when the template is expanded.

## ◆ Target

string MacroAttribute.Target

get set

Identifies the target parameter of a source template if the MacroAttribute is applied on a template method.

The documentation for this class was generated from the following file:

- Properties/Annotations.cs