CodeSmith模板(一)

开始学习CodeSmith模板。

首先,是基本模板:

<%@ CodeTemplate Language="C#" TargetLanguage="C#"
      Description
="Generates a class including a special informational header" %>
 
<%@ Property Name="NameSpace" Type="String"
      Category
="Context"
      Description
="The namespace to use for this class" %>
 
<%@ Property Name="ClassName" Type="String"
      Category
="Context"
      Description
="The name of the class to generate" %>
 
<%@ Property Name="DevelopersName" Type="String"
      Category
="Context"
      Description
="The name to include in the comment header" %>

///
// File: <%=ClassName%>.cs
// Description: Enter summary here after generation.
// ---------------------
// Copyright © <%= DateTime.Now.Year %> Our Client
// ---------------------
// History
//    <%= DateTime.Now.ToShortDateString() %>    <%= DevelopersName%>    Original Version
///
 
using System;
 
namespace <%=NameSpace %>
{
      
/// <summary>
      
/// Summary description for <%=ClassName %>.
      
/// </summary>
      public class <%=ClassName %>
      {
            
public <%=ClassName %>()
            {
                  
//
                  // TODO: Add constructor logic here
                  //
            }
      }
}

该模板定义了三个属性,这三个属性如果直接Execute,Explorer里就会出现三个属性,点击“生成”,右边会生成C#代码。

有个小技巧,如何让Codesmith支持中文:

1、Studio里,设置Tools-->Options,对话框里面Enable Unicode support复选框勾选上;

2、模板里加入:ResponseEncoding="UTF-8",修改后的代码诸如:<%@ CodeTemplate Language="C#" ResponseEncoding="UTF-8" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Generate Model Class for a specific Data Table" %>

3、用记事本打开cst文件,另存为utf-8格式。

转载于:https://www.cnblogs.com/anrerbo/archive/2011/01/30/1947719.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3.1.zip codesmith 模板codesmith nettiers-2.3
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值