zoukankan      html  css  js  c++  java
  • CodeSmith ActiveSnippet

    CodeSmith的ActiveSnippet 设置见 http://www.codesmithtools.com/usersguide/Using_ActiveSnippets.html#

    填充属性模板


    <%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Template description here." %>
    <%@ Property Name="typeandname" Type="System.String" Default="" Optional="True" Category="Strings" Description="" %>
    <%@ Assembly Name="System.Data" %>
    <%@ Import Namespace="System.Data" %>
    <%
    string[] ary0 = typeandname.Split(',');
    foreach(string s in ary0)
    {
        string[] ary = s.Split(' ');
    %>
    <%=ary[0]%> <%=(ary[1].ToLower())%> ;
    public <%=ary[0]%> <%=ary[1]%>
    {
        get
        {
            return <%=(ary[1].ToLower())%>;
        }
        set
        {
            <%=(ary[1].ToLower())%> = value;
        }
    }
    <%
    }
    %>

    在 VS2005 中的Snippet Configuration中添加当前模板,并设置别名为"cp"

    在类中写入如下语句 cp "int CID,string CNAME"  然后 通过右键菜单中的 Expand ActiveSnippet或连按两次 CTRL-E生成如下代码

           int cid;
           public int CID
           {
               get
               {
                   return cid;
               }
               set
               {
                   cid = value;
               }
           }
           string cname;
           public string CNAME
           {
               get
               {
                   return cname;
               }
               set
               {
                   cname = value;
               }
           }

    当然了对于一些通用代码这样处理,效率很不错。

  • 相关阅读:
    js返回到顶部
    css培训一
    css常用hack技巧
    css培训二
    css样式渲染规则
    html语义(一)
    css样式表管理
    html+css培训方案
    继承
    封装
  • 原文地址:https://www.cnblogs.com/rock_chen/p/926457.html
Copyright © 2011-2022 走看看