forked from pedropombeiro/FactoryGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefaultTemplate.render
66 lines (56 loc) · 1.54 KB
/
DefaultTemplate.render
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma warning disable 1591
{{#if OuterUsings}}
{{OuterUsings}}
{{/if}}
namespace {{Namespace}}
{
{{InnerUsings}}
/// <summary>
/// The implementation for the factory generating <see cref="{{Class.ConcreteClassName}}" /> instances.
/// </summary>
{{#each Class.Attributes}}
[{{Name}}{{#if Arguments}}({{#each Arguments}}{{&Text}}{{^IsLast}}, {{/IsLast}}{{/each}}){{/if}}]
{{/each}}
public partial class {{Class.Name}}{{#Class.GenericTypes}}<{{&Class.GenericTypes}}>{{/Class.GenericTypes}} : {{&Class.Inherit}}
{
{{#if Class.Fields}}
#region Fields
{{#each Class.Fields}}
private readonly {{&Type}} {{Name}};
{{/each}}
#endregion
{{/if}}
{{#if Class.Constructor}}
#region Constructors
public {{Class.Name}} (
{{#each Class.Constructor.Arguments}}
{{&Attribute}} {{&Type}} {{Name}}{{#if IsLast}}){{#else}}, {{/if}}
{{/each}}
{
{{#each Class.Fields}}
this.{{Name}} = {{Name}};
{{/each}}
}
#endregion
{{/if}}
{{#if Class.Methods}}
#region Public Factory Methods
{{#each Class.Methods}}
{{#if XmlDoc}}
{{&XmlDoc}}
{{/if}}
public {{&ReturnType}} {{Name}}{{#GenericTypes}}<{{&GenericTypes}}>{{/GenericTypes}}({{^Arguments}}){{/Arguments}}
{{#each Arguments}}
{{&Attribute}} {{&Type}} {{Name}}{{#if IsLast}}){{#else}}, {{/if}}
{{/each}}
{
return new {{&NewInstanceType}} ({{^ImplementationParameters}});{{/ImplementationParameters}}
{{#each ImplementationParameters}}
{{&Value}}{{#if IsLast}});{{#else}}, {{/if}}
{{/each}}
}
{{/each}}
#endregion
{{/if}}
}
}