CodeSmith实用技巧(十):通过编程执行模版
CodeSmith 在执行模版时通过调用一些 API 来完成的,主要经过了以下这几步的操作: l 编译一个模版 l 显示编译错误信息 l 创建一个新的模版实例 l 用元数据填充模版 l 输出结果 下面这段代码显示了这些操作: CodeTemplateCompilercompiler = new CodeTempla
CodeSmith在执行模版时通过调用一些API来完成的,主要经过了以下这几步的操作:
l 编译一个模版
l 显示编译错误信息
l 创建一个新的模版实例
l 用元数据填充模版
l 输出结果
下面这段代码显示了这些操作:
在这里我们用了CodeTemplateCompiler compiler = new CodeTemplateCompiler("..\\..\\StoredProcedures.cst");
compiler.Compile();
if (compiler.Errors.Count == 0)
{
CodeTemplate template = compiler.CreateInstance();
DatabaseSchema database = new DatabaseSchema(new SqlSchemaProvider(), @"Server=(local)\NetSDK;Database=Northwind;Integrated Security=true;");
TableSchema table = database.Tables["Customers"];
template.SetProperty("SourceTable", table);
template.SetProperty("IncludeDrop", false);
template.SetProperty("InsertPrefix", "Insert");
template.Render(Console.Out);
}
else
{
for (int i = 0; i compiler.Errors.Count; i++)
{
Console.Error.WriteLine(compiler.Errors[i].ToString());
}
}

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)