<pre class="csharp" name="code">1.如何将属性设置成选择一个文件夹的路径
[Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string OutputDirectory
{
get {return _outputDirectory;}
set {_outputDirectory= value;}
}
2.怎样调用子模板
<pre class="csharp" name="code">1<%
2foreach (TableSchema table in SourceDatabase.Tables)
3{
4 OutputSubTemplate(table);
5}
6%>
7<script runat="template">
8private CodeTemplate _mySubTemplate;
9
10[Browsable(false)]
11public CodeTemplate MySubTemplate
12{
13 get
14 {
15 if (_mySubTemplate == null)
16 {
17 CodeTemplateCompiler compiler = new CodeTemplateCompiler(this.CodeTemplateInfo.DirectoryName + "MySubTemplate.cst");
18 compiler.Compile();
19 if (compiler.Errors.Count == 0)
20 {
21 _mySubTemplate = compiler.CreateInstance();
22 }
23 else
24 {
25 for (int i = 0; i < compiler.Errors.Count; i++)
26 {
27 Response.WriteLine(compiler.Errors[ i].ToString());
28 }
29 }
30 }
31 return _mySubTemplate;
32 }
33}
34
35public void OutputSubTemplate(TableSchema table)
36{
37 MySubTemplate.SetProperty("SourceTable", table);
38 MySubTemplate.SetProperty("IncludeDrop", false);
39 MySubTemplate.SetProperty("InsertPrefix", "Insert");
40 MySubTemplate.Render(Response);
41}
42</script></pre>
</pre>
[Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string OutputDirectory
{
get {return _outputDirectory;}
set {_outputDirectory= value;}
}
2.怎样调用子模板
<pre class="csharp" name="code">1<%
2foreach (TableSchema table in SourceDatabase.Tables)
3{
4 OutputSubTemplate(table);
5}
6%>
7<script runat="template">
8private CodeTemplate _mySubTemplate;
9
10[Browsable(false)]
11public CodeTemplate MySubTemplate
12{
13 get
14 {
15 if (_mySubTemplate == null)
16 {
17 CodeTemplateCompiler compiler = new CodeTemplateCompiler(this.CodeTemplateInfo.DirectoryName + "MySubTemplate.cst");
18 compiler.Compile();
19 if (compiler.Errors.Count == 0)
20 {
21 _mySubTemplate = compiler.CreateInstance();
22 }
23 else
24 {
25 for (int i = 0; i < compiler.Errors.Count; i++)
26 {
27 Response.WriteLine(compiler.Errors[ i].ToString());
28 }
29 }
30 }
31 return _mySubTemplate;
32 }
33}
34
35public void OutputSubTemplate(TableSchema table)
36{
37 MySubTemplate.SetProperty("SourceTable", table);
38 MySubTemplate.SetProperty("IncludeDrop", false);
39 MySubTemplate.SetProperty("InsertPrefix", "Insert");
40 MySubTemplate.Render(Response);
41}
42</script></pre>
</pre>