-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDocumentationPageTemplate.cs
123 lines (106 loc) · 3.07 KB
/
DocumentationPageTemplate.cs
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Reflection;
using Invert.Core.GraphDesigner;
[TemplateClass(TemplateLocation.Both,"{0}Page")]
public class DocumentationPageTemplate : DocumentationPage, IClassTemplate<IDocumentable>
{
public string OutputPath
{
get { return Path2.Combine("Documentation","Editor", "Pages"); }
}
public bool CanGenerate
{
get { return true; }
}
public void TemplateSetup()
{
var className = Ctx.Data.Node.Name + "Page";
if (Ctx.Data.Node != Ctx.Data)
{
className = Ctx.Data.Node.Name.Clean() + Ctx.Data.Name.Clean() + "Page";
}
if (Ctx.IsDesignerFile)
{
className += "Base";
}
Ctx.CurrentDeclaration.Name = className;
if (Ctx.IsDesignerFile)
{
if (this.Ctx.Data.Node.Graph.RootFilter != Ctx.Data)
{
Ctx.SetBaseType(this.Ctx.Data.Node.Graph.RootFilter.Name.Clean() + "Page");
}
}
else
{
Ctx.SetBaseType(className + "Base");
}
if (Ctx.IsDesignerFile || this.Ctx.Data.Node.Graph.RootFilter == Ctx.Data)
{
Ctx.CurrentDeclaration.TypeAttributes |= TypeAttributes.Abstract;
//Ctx.CurrentDecleration.Attributes = MemberAttributes.Abstract | MemberAttributes.Public;
}
}
public TemplateContext<IDocumentable> Ctx { get; set; }
[GenerateProperty(TemplateLocation.DesignerFile)]
public override Type ParentPage
{
get
{
if (Ctx.Data != Ctx.Data.Node.Graph.RootFilter)
{
if (Ctx.Data.Node != Ctx.Data)
{
Ctx._("return typeof({0}PageBase)", Ctx.Data.Node.Name);
}
else
{
Ctx._("return null");
}
}
else
{
Ctx._("return null");
}
return null;
}
}
[GenerateProperty(TemplateLocation.DesignerFile)]
public override Type RelatedNodeType
{
get
{
var classType = Ctx.Data as IClassTypeNode;
if (classType != null)
{
Ctx._("return typeof({0})", classType.ClassName);
}
else
{
Ctx._("return typeof({0})", Ctx.Data.Name);
}
return null;
}
set { base.RelatedNodeType = value; }
}
[GenerateProperty(TemplateLocation.DesignerFile)]
public override string Name
{
get
{
if (Ctx.CurrentDeclaration.TypeAttributes == TypeAttributes.Abstract)
{
Ctx._("return base.Name");
}
else
{
Ctx._("return \"{0}\"", Ctx.Data.Name);
}
return null;
}
}
[GenerateMethod(TemplateLocation.Both)]
public override void GetContent(IDocumentationBuilder _)
{
}
}