惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
K
Kaspersky official blog
A
Arctic Wolf
Attack and Defense Labs
Attack and Defense Labs
L
LINUX DO - 热门话题
N
News | PayPal Newsroom
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
Lohrmann on Cybersecurity
PCI Perspectives
PCI Perspectives
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Last Watchdog
The Last Watchdog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
W
WeLiveSecurity
Know Your Adversary
Know Your Adversary
博客园 - Franky
T
Tenable Blog
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Help Net Security
Help Net Security
WordPress大学
WordPress大学
T
The Exploit Database - CXSecurity.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
S
Security Affairs
J
Java Code Geeks
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Apple Machine Learning Research
Apple Machine Learning Research
NISL@THU
NISL@THU
O
OpenAI News
The Cloudflare Blog
月光博客
月光博客
Google Online Security Blog
Google Online Security Blog
V
V2EX
罗磊的独立博客
美团技术团队
博客园 - 三生石上(FineUI控件)
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
L
LINUX DO - 最新话题
Hacker News - Newest:
Hacker News - Newest: "LLM"
大猫的无限游戏
大猫的无限游戏

博客园 - ~在思考中沉淀~

寻找合租的朋友;-) [晴,天气不错]咖啡罐上的灰尘 辛苦的周末~ 结合Web Services和Windows Services定期执行Asp.Net代码 可怕的春运,烦人的火车票! RSS Reader\Workflow Lite\User Manager for Sharepoint以及一点想法 - ~在思考中沉淀~ 创建自定义的Visual Studio项模板 微软推出Microsoft Exchange Server Best Practices Analyzer Tool 有要Gmail的吗?;)[已结束!] 分析更新LastActivity的过程-补Who is online 科技对生活的影响 WhoIsOnline ;) - 解读CNForum源码中在线用户统计 创建VS.Net外接程序时遇到的问题 开始GMail之旅 .Net和Windows应用程序调试[更新至2004-12-29] 学习SQL Server全文索引 惊喜->监护期 悲哀的晚上 my代码分析器
VS2005中通过code snippet定制类模板
~在思考中沉淀~ · 2006-01-05 · via 博客园 - ~在思考中沉淀~

[自从去年4月到新公司后就没有再写BLOG了,不过还好没被DUDU除名;-)。www.andrewbao.com]
曾经在VS2003中为了定制项模板费了很多事才实现,如果你对VS2003中怎么实现项模板可以参考我过去的一篇Blog 创建自定义的Visual Studio项模板
随着VS2005的发布,我们有了更多的选择,对于定制某种类的样式来说,可以简单的通过创建Code Snippet样式来实现。下面还是以应用Singleton模式的类为例。
首先我们创建一个文件,比如名字叫Singleton.snippet,内容如下:

    1 <?xml version="1.0" encoding="utf-8" ?>

    2 <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">

    3 <CodeSnippet Format="1.0.0">

    4           <Header>

    5                    <Title>Singleton</Title>

    6                    <Shortcut>Singleton</Shortcut>

    7                    <Description>singleton class</Description>

    8                    <Author>AndrewBao</Author>

    9                    <SnippetTypes>

   10                             <SnippetType>Expansion</SnippetType>

   11                    </SnippetTypes>

   12           </Header>

   13           <Snippet>

   14                    <Declarations>

   15                             <Literal>

   16                                       <ID>classname</ID>

   17                                       <ToolTip>Class name</ToolTip>

   18                                       <Default>SingletonSample</Default>

   19                             </Literal>

   20                             <Literal>

   21                                       <ID>type</ID>

   22                                       <ToolTip>Instance Type</ToolTip>

   23                                       <Default>SingletonSample</Default>

   24                             </Literal>

   25                             <Literal>

   26                                       <ID>field</ID>

   27                                       <ToolTip>Single Instance of SingleSample</ToolTip>

   28                                       <Default>MySingleObj</Default>

   29                             </Literal>

   30                             <Literal>

   31                                       <ID>method</ID>

   32                                       <ToolTip>Get Instance Method</ToolTip>

   33                                       <Default>GetInstance</Default>

   34                             </Literal>

   35                    </Declarations>

   36                    <Code Language="csharp">

   37                             <![CDATA[class $classname$

   38           {

   39             static private $classname$ $field$ = null;           

   40             protected $classname$()

   41             {

   42             }

   43             public static $classname$ $method$()

   44             {

   45                 if ($field$ == null)

   46                     $field$ = new $classname$();

   47                 return $field$;

   48             }

   49           }]]>

   50                    </Code>

   51           </Snippet>

   52 </CodeSnippet>

   53 </CodeSnippets>

然后通过VS2005中Tools->Code Snippets Manager将此snippet模板导入,如下图

OK,开始应用这个模板,应用的方式和结果如下图:

怎么样,很简单吧! 还有两个相关资源可以使用:

1.gotcodesnippets 分享CodeSnippet模板的网站
2.Snippy - VS2005 Code Snippet Editor