现在的位置: 首页 > 综合 > 正文

About-CodeSmith(转)

2014年01月28日 ⁄ 综合 ⁄ 共 2059字 ⁄ 字号 评论关闭
<%@ 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
                  
//
            }

      }

}

抱歉!评论已关闭.