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