zoukankan      html  css  js  c++  java
  • Visual Studio 2010自动添加头部注释信息

      在日常的开发中我们经常需要为我们的类库添加注释和版权等信息,这样我们就需要每次去拷贝粘贴同样的文字,为了减少这种重复性的工作,我们可以把这些信息保存在Visual Studio 2010类库模版文件里。

      首先找到Visual Studio 2010的安装路径下Common7IDEItemTemplatesCacheCSharp目录;

      里面有好多目录,Windows Forms是开发Windows Forms程序的模版目录,Web是Web项目文件的模版目录,其他的同理。进入Web目录有选择2052目录(2052是中文地区的代号)下,会看到好多带有.zip的目录,比如我要修改类的模版,就修改WebClass.zipClass.cs,打开Class.cs会看到如下内容:

    using System;
    using System.Collections.Generic;
    $if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
    $endif$using System.Web;
    
    namespace $rootnamespace$
    {
        public class $safeitemrootname$
        {
        }
    }

      我们在顶部加入注释后,代码如下:

    /*
     * Project Name :$rootnamespace$ 
     * Class Name   :$safeitemrootname$
     * Class Version:V1.0.0.0
     * 
     * Created by $username$ on $time$.
     * Copyright © $year$ Jinxixin. All rights reserved.
     */
    using System;
    using System.Collections.Generic;
    $if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
    $endif$using System.Web;
    
    namespace $rootnamespace$
    {
        public class $safeitemrootname$
        {
        }
    }

      将修改后的文件重新打包成WebClass.zip文件,替换原来的WebClass.zip文件。  

      最后,以管理员身份打开Visual Studio 2010命令提示工具,执行devenv /InstallVsTemplates,即可。

      Mark:模板变量含义如下:

    $time$     日期
    $year$     年份
    $clrversion$    CLR版本
    $GUID$   用于替换项目文件中的项目 GUID 的 GUID。最多可以指定 10 个唯一的 GUID(例如,guid1))。
    $itemname$  用户在对话框中提供的名称。
    $machinename$    当前的计算机名称(例如,Computer01)。
    $projectname$   用户在对话框中提供的名称。
    $registeredorganization$   HKLMSoftwareMicrosoftWindows NTCurrentVersionRegisteredOrganization 中的注册表项值。
    $rootnamespace$  当前项目的根命名空间。此参数用于替换正向项目中添加的项中的命名空间。
    $safeitemname$  用户在“添加新项”对话框中提供的名称,名称中移除了所有不安全的字符和空格。
    $safeprojectname$  用户在“新建项目”对话框中提供的名称,名称中移除了所有不安全的字符和空格。
    $time$    以 DD/MM/YYYY 00:00:00 格式表示的当前时间。
    $userdomain$  当前的用户域。
    $username$  当前的用户名。
  • 相关阅读:
    Python 多线程学习(转)
    自己使用python webob,paste.deploy,wsgi总结
    Python中*args 和**kwargs的用法
    python 数字和字符串转换问题
    python socket编程
    深入解读Quartz的原理
    解决get方法传递URL参数中文乱码和解决tomcat下中文乱码问题
    Tomcat的Manager显示403 Access Denied
    mysql5.6 linux下安装笔记
    Quartz应用与集群原理分析
  • 原文地址:https://www.cnblogs.com/AngelLee2009/p/3203765.html
Copyright © 2011-2022 走看看