annotate Source/Templates/VB.ttinclude @ 4:f757da6161a1

!bug 100 + 2h fixed gregression
author cin
date Sun, 24 Aug 2014 17:57:42 +0400
parents f990fcb411a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
1 <#
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
2
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
3 OneToManyAssociationType = OneToManyAssociationType.Replace("<", "(Of ").Replace(">", ")");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
4
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
5 WriteComment = (tt,s) => WriteLine("'{0}", s);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
6 WriteUsing = (tt,s) => WriteLine("Imports {0}", s);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
7 WriteBeginNamespace = (tt,s) => { WriteLine("Namespace {0}", s); WriteLine(""); };
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
8 WriteEndNamespace = tt => { WriteLine(""); WriteLine("End Namespace"); };
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
9 WriteBeginClass = (tt,cl,bc) =>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
10 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
11 WriteLine("Public Partial Class {0}", cl);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
12 if (!string.IsNullOrEmpty(bc))
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
13 WriteLine("\tInherits {0}", bc);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
14 };
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
15 WriteEndClass = tt => WriteLine("End Class");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
16 MakeGenericType = (c,t) => string.Format("{0}(Of {1})", c, t);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
17 WriteTableProperty = (tt,name,pname,maxlen,maxplen) =>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
18 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
19 WriteLine("");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
20 WriteLine("Public ReadOnly Property {0}(){1} As Table(Of {2})", pname, LenDiff(maxplen, pname), name);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
21 WriteLine("\tGet");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
22 WriteLine("\t\tReturn Me.GetTable(Of {0})()", name);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
23 WriteLine("\tEnd Get");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
24 WriteLine("End Property");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
25 };
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
26 WriteAttribute = (tt,a) => WriteLine("<{0}> _", a.Replace("=", ":="));
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
27 WriteAttributeLine = tt => {};
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
28
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
29 RenderColumn = (tt,c,maxLens,attrs) =>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
30 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
31 WriteLine("");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
32
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
33 var type = MakeType(c.Type);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
34
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
35 if (!tt.RenderField)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
36 WriteLine("Private _{0} As {1}", c.MemberName, type);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
37
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
38 attrs = attrs.Where(_ => _ != null).ToArray();
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
39
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
40 if (attrs.Length > 0)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
41 WriteLine("<{0}> _", string.Join(", ", attrs).Replace("=", ":="));
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
42
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
43 if (tt.RenderField)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
44 WriteLine("Public {0} As {1}", c.MemberName, type);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
45 else
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
46 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
47 WriteLine("Public Property {0} As {1}", c.MemberName, type);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
48 WriteLine("\tGet");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
49 WriteLine("\t\tReturn Me._{0}", c.MemberName);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
50 WriteLine("\tEnd Get");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
51 WriteLine("\tSet");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
52 WriteLine("\t\tMe._{0} = value", c.MemberName);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
53 WriteLine("\tEnd Set");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
54 WriteLine("End Property");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
55 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
56 };
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
57
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
58 RenderForeignKey = (tt,key) =>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
59 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
60 WriteComment(tt, " " + key.KeyName);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
61
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
62 var type = "" ;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
63 if (key.AssociationType == AssociationType.OneToMany)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
64 type = string.Format(OneToManyAssociationType, key.OtherTable.ClassName);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
65 else
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
66 type = key.OtherTable.ClassName ;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
67
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
68 if (!RenderField)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
69 WriteLine("Private _{0} As {1}", key.MemberName, type);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
70
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
71 WriteLine("<Association(ThisKey:=\"{0}\", OtherKey:=\"{1}\")> _",
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
72 string.Join(", ", (from c in key.ThisColumns select c.MemberName).ToArray()),
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
73 string.Join(", ", (from c in key.OtherColumns select c.MemberName).ToArray()));
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
74
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
75 if (RenderField)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
76 WriteLine("Public {0} As {1}", key.MemberName, type);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
77 else
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
78 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
79 WriteLine("Public Property {0} As {1}", key.MemberName, type);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
80 WriteLine("\tGet");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
81 WriteLine("\t\tReturn Me._{0}", key.MemberName);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
82 WriteLine("\tEnd Get");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
83 WriteLine("\tSet");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
84 WriteLine("\t\tMe._{0} = value", key.MemberName);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
85 WriteLine("\tEnd Set");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
86 WriteLine("End Property");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
87 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
88 };
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
89
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
90 MakeType = t =>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
91 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
92 switch (t)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
93 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
94 case "byte[]" : return "Byte()";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
95 case "string" : return "String";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
96 case "byte" : return "Byte";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
97 case "byte?" : return "Byte?";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
98 case "bool" : return "Boolean";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
99 case "bool?" : return "Boolean?";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
100 case "object" : return "Object";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
101 case "short" : return "Short";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
102 case "short?" : return "Short?";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
103 case "decimal" : return "Decimal";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
104 case "decimal?" : return "Decimal?";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
105 case "int" : return "Integer";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
106 case "int?" : return "Integer?";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
107 case "float" : return "Single";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
108 case "float?" : return "Single?";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
109 case "double" : return "Double";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
110 case "double?" : return "Double?";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
111 case "long" : return "Long";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
112 case "long?" : return "Long?";
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
113 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
114
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
115 return t;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
116 };
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
117 #>