About-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
                  //
            }
      }
}

看着上面的代码,是不是感觉很熟悉?是的,它的语法很像asp.net的语法,这样,大家就不需要花费太多时间来学习了。

其生成结果如下:

 

///
//  File: Hello.cs
//  Description: Enter summary here after generation.
//  ---------------------
//  Copyright c 2005 Our Client
//  ---------------------
//  History
//     2005-1-18    Tim Wang    Original Version
///
 
using  System;
 
namespace  ASPCOOL
{
      
/// <summary>
      
/// Summary description for Hello.
      
/// </summary>

      public class Hello
      
{
            
public Hello()
            
{
                  
//
                  
// TODO: Add constructor logic here
                  
//
            }

      }

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值