-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecordGenHelper.tt
53 lines (46 loc) · 2.22 KB
/
RecordGenHelper.tt
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
<#@ Assembly name="$(SolutionDir)\bin\WellTyped.CodeGen.dll" #>
<#@ template debug="true" hostSpecific="true" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#+ public void GenerateRecord(string recordDef)
{
string cls = "";
try
{
cls = CodeGen.Record.Generate(recordDef);
}
catch (Exception ex)
{
this.Error(ex.Message);
}
PushIndent("\t");
#>
<#= cls #>
<#+
PopIndent();
}
public void GenerateDiscriminatedUnion(string duDef)
{
string cls = "";
try
{
cls = CodeGen.DU.Generate(duDef);
}
catch (Exception ex)
{
this.Error(ex.Message);
}
PushIndent("\t");
#>
<#= cls #>
<#+
PopIndent();
}
void SaveOutput(string outputFileName)
{
string templateDirectory = Path.GetDirectoryName(Host.TemplateFile);
string outputFilePath = Path.Combine(templateDirectory, outputFileName);
File.WriteAllText(outputFilePath, this.GenerationEnvironment.ToString());
//this.GenerationEnvironment.Remove(0, this.GenerationEnvironment.Length);
}
#>