RingSoft.DbLookup.Controls.WPF.Properties Namespace
RingSoft.DbMaintenance Namespace

SourceTemplateAttribute Class

An extension method marked with this attribute is processed by code completion as a 'Source Template'. When the extension method is completed over some expression, its source code is automatically expanded like a template at call site.

Namespace:  RingSoft.DbMaintenance
Assembly:  RingSoft.DbMaintenance (in RingSoft.DbMaintenance.dll)

Syntax


[AttributeUsageAttribute]
public sealed class SourceTemplateAttribute : Attribute
<AttributeUsageAttribute> _
Public NotInheritable Class SourceTemplateAttribute _
	Inherits Attribute
[AttributeUsageAttribute]
public ref class SourceTemplateAttribute sealed : public Attribute

Remarks


Template method body can contain valid source code and/or special comments starting with '$'. Text inside these comments is added as source code when the template is applied. Template parameters can be used either as additional method parameters or as identifiers wrapped in two '$' signs. Use the MacroAttribute attribute to specify macros for parameters.

Examples


In this example, the 'forEach' method is a source template available over all values of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block:
C#
[SourceTemplate]
public static void forEach<T>(this IEnumerable<T> xs) {
foreach (var x in xs) {
//$ $END$
}
}

Inheritance Hierarchy


Object
  Attribute
    RingSoft.DbMaintenance..::..SourceTemplateAttribute