CommonUtility.cst
1
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Src="" Description="" %>
2
<%@ Assembly Name="SchemaExplorer" %>
3
<%@ Assembly Name="System.Data" %>
4
<%@ Import Namespace="SchemaExplorer" %>
5
<%@ Import Namespace="System.Data" %>
6
<%@ Property Name="TableCollection" Type="SchemaExplorer.TableSchemaCollection" Category="Context" Description="Tables wicth used to generate utility"%>
7
<%@ Assembly Src="CommonUtility.cs" %>
8
<%@ Property Name="NameSpace" Type="System.String" Category="" Description="" %>
9
<%@ Property Name="ClassName" Type="System.String" Description="" %>
10
<%@ Property Name="AutherName" Type="System.String" Default="Slash" Description="" %>
11
<%@ Import Namespace="Common.Data" %>
12
<script runat="template">
13
CommonUtility rule=new CommonUtility();
14
</script>
15
/////////////////////////////
16
//File:<%= ClassName %>.cs
17
//Data Created:<%= DateTime.Now.ToLongDateString() %>
18
//Created by:<%= AutherName %>
19
/////////////////////////////
20
namespace <%= NameSpace %>
21
{
22
using System;
23
using System.Data;
24
using System.Runtime.Serialization;
25
26
/// <summary>
27
/// A custom serializable dataset containing order information.
28
/// <remarks>
29
/// This class is used to define the shape of OrderData.
30
/// </remarks>
31
/// <remarks>
32
/// The serializale constructor allows objects of type OrderData to be remoted.
33
/// </remarks>
34
/// </summary>
35
[System.ComponentModel.DesignerCategoryAttribute("Code")]
36
[SerializableAttribute]
37
public class <%= ClassName %> : DataSet
38
{
39
40
<%for(int k=0;k<TableCollection.Count;k++) %>
41
<%{%>
42
43
//
44
//<%=rule.GetCamelCaseName(TableCollection[k].Name) %> items table constants
45
//
46
///<value>The constant used for <%= rule.GetCamelCaseName(TableCollection[k].Name) %> table.</value>
47
<%= rule.GetTableConstantDeclarationStatement(TableCollection[k]) %>;
48
<%for(int i=0;i<TableCollection[k].Columns.Count;i++) %>
49
<%{ %>
50
///<value>The constant used for <%= TableCollection[k].Columns[i].Name %> field in the <%= rule.GetCamelCaseName(TableCollection[k].Name) %> table.</value>
51
<%= rule.GetMemberConstantDeclarationStatement(TableCollection[k].Columns[i])%>;
52
<%} %>
53
<%} %>
54
55
/// <summary>
56
/// Constructor to support serialization.
57
/// <remarks>Constructor that supports serialization.</remarks>
58
/// <param name="info">The SerializationInfo object to read from.</param>
59
/// <param name="context">Information on who is calling this method.</param>
60
/// </summary>
61
private <%= ClassName %>(SerializationInfo info,StreamingContext context):base(info,context)
62
{
63
}
64
65
/// <summary>
66
/// Constructor for <%= ClassName %>.
67
/// <remarks>Initialize a <%= ClassName %>instance by building the table schema.</remarks>
68
/// </summary>
69
public <%= ClassName %>
70
{
71
//
72
//Create the tables in the dataset
73
//
74
BuildDataTables();
75
}
76
77
///----------------------------------------------------------------
78
/// Sub BuildDataTables:
79
/// Creates the following datatables: OrderItems, OrderSummary,
80
/// Customer, ShippingAddress, Payment, Order
81
///----------------------------------------------------------------
82
private void BuildDataTables()
83
{
84
///
85
///create the <%= TableCollection[0].Name %> items table.
86
///
87
DataTable table=new DataTable(<%= rule.GetCamelCaseName(TableCollection[0].Name)%>);
88
DataColumnCollection columns=table.Columns;
89
90
<% for(int i=0;i<TableCollection.Count;i++)%>
91
<% {%>
92
<% for(int m=0;m<TableCollection[i].Columns.Count;m++)%>
93
<%{ %>
94
columns.Add(<%= rule.GetCamelCaseName(TableCollection[i].Columns[m].Name)%>,typeof(<%= rule.GetCSharpBaseType(TableCollection[i].Columns[m])%>));
95
<% }%>
96
<%} %>
97
this.Tables.Add(table);
98
}
99
100
}
101
}
102![]()
103![]()
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Src="" Description="" %>2
<%@ Assembly Name="SchemaExplorer" %> 3
<%@ Assembly Name="System.Data" %> 4
<%@ Import Namespace="SchemaExplorer" %> 5
<%@ Import Namespace="System.Data" %> 6
<%@ Property Name="TableCollection" Type="SchemaExplorer.TableSchemaCollection" Category="Context" Description="Tables wicth used to generate utility"%>7
<%@ Assembly Src="CommonUtility.cs" %> 8
<%@ Property Name="NameSpace" Type="System.String" Category="" Description="" %> 9
<%@ Property Name="ClassName" Type="System.String" Description="" %>10
<%@ Property Name="AutherName" Type="System.String" Default="Slash" Description="" %>11
<%@ Import Namespace="Common.Data" %>12
<script runat="template">13
CommonUtility rule=new CommonUtility();14
</script>15
/////////////////////////////16
//File:<%= ClassName %>.cs17
//Data Created:<%= DateTime.Now.ToLongDateString() %>18
//Created by:<%= AutherName %>19
/////////////////////////////20
namespace <%= NameSpace %> 21
{22
using System;23
using System.Data;24
using System.Runtime.Serialization;25
26
/// <summary>27
/// A custom serializable dataset containing order information.28
/// <remarks>29
/// This class is used to define the shape of OrderData.30
/// </remarks>31
/// <remarks>32
/// The serializale constructor allows objects of type OrderData to be remoted.33
/// </remarks>34
/// </summary>35
[System.ComponentModel.DesignerCategoryAttribute("Code")]36
[SerializableAttribute]37
public class <%= ClassName %> : DataSet38
{39
40
<%for(int k=0;k<TableCollection.Count;k++) %>41
<%{%>42
43
//44
//<%=rule.GetCamelCaseName(TableCollection[k].Name) %> items table constants45
//46
///<value>The constant used for <%= rule.GetCamelCaseName(TableCollection[k].Name) %> table.</value>47
<%= rule.GetTableConstantDeclarationStatement(TableCollection[k]) %>;48
<%for(int i=0;i<TableCollection[k].Columns.Count;i++) %>49
<%{ %>50
///<value>The constant used for <%= TableCollection[k].Columns[i].Name %> field in the <%= rule.GetCamelCaseName(TableCollection[k].Name) %> table.</value>51
<%= rule.GetMemberConstantDeclarationStatement(TableCollection[k].Columns[i])%>; 52
<%} %>53
<%} %>54
55
/// <summary>56
/// Constructor to support serialization.57
/// <remarks>Constructor that supports serialization.</remarks> 58
/// <param name="info">The SerializationInfo object to read from.</param>59
/// <param name="context">Information on who is calling this method.</param>60
/// </summary>61
private <%= ClassName %>(SerializationInfo info,StreamingContext context):base(info,context)62
{63
}64
65
/// <summary>66
/// Constructor for <%= ClassName %>. 67
/// <remarks>Initialize a <%= ClassName %>instance by building the table schema.</remarks> 68
/// </summary>69
public <%= ClassName %>70
{71
//72
//Create the tables in the dataset73
//74
BuildDataTables();75
}76
77
///----------------------------------------------------------------78
/// Sub BuildDataTables:79
/// Creates the following datatables: OrderItems, OrderSummary, 80
/// Customer, ShippingAddress, Payment, Order81
///----------------------------------------------------------------82
private void BuildDataTables()83
{84
///85
///create the <%= TableCollection[0].Name %> items table.86
///87
DataTable table=new DataTable(<%= rule.GetCamelCaseName(TableCollection[0].Name)%>);88
DataColumnCollection columns=table.Columns;89
90
<% for(int i=0;i<TableCollection.Count;i++)%>91
<% {%>92
<% for(int m=0;m<TableCollection[i].Columns.Count;m++)%>93
<%{ %>94
columns.Add(<%= rule.GetCamelCaseName(TableCollection[i].Columns[m].Name)%>,typeof(<%= rule.GetCSharpBaseType(TableCollection[i].Columns[m])%>));95
<% }%>96
<%} %>97
this.Tables.Add(table);98
}99
100
}101
}102

103



浙公网安备 33010602011771号