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

推荐订阅源

B
Blog RSS Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
GRAHAM CLULEY
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cybersecurity and Infrastructure Security Agency CISA
Simon Willison's Weblog
Simon Willison's Weblog
Latest news
Latest news
C
CERT Recently Published Vulnerability Notes
T
Threatpost
V
Vulnerabilities – Threatpost
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
C
Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
U
Unit 42
The Register - Security
The Register - Security
T
The Blog of Author Tim Ferriss
Stack Overflow Blog
Stack Overflow Blog
The Hacker News
The Hacker News
AI
AI
Project Zero
Project Zero
Scott Helme
Scott Helme
S
Securelist
Vercel News
Vercel News
GbyAI
GbyAI
S
Security @ Cisco Blogs
I
InfoQ
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
Forbes - Security
Forbes - Security
Google Online Security Blog
Google Online Security Blog
W
WeLiveSecurity
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Heimdal Security Blog
G
Google Developers Blog
D
DataBreaches.Net
The Last Watchdog
The Last Watchdog
D
Docker
MyScale Blog
MyScale Blog
T
Tor Project blog
Cyberwarzone
Cyberwarzone
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
T
Tenable Blog
T
Threat Research - Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 聂微东
月光博客
月光博客

博客园 - Justin Shen

[.Net 4.0]泛型的协变,以及高阶函数对泛型的影响 Part 1 随笔 - WCF and Data Service - Justin Shen 面向对象语言中的Environment和Binding 元数据 有多少东西需要学习? [电子书下载]Dissecting a C# Application: Inside SharpDevelop [MSDNTV]Don Box再次出击 :) 追踪你的时间使用状况 听说《csdn开发高手》停刊了 在nant中改变编译的目标平台 让使用MSN就像访问网页一样容易! System.String是不可变的字符串吗? 对中国计算机大学教育的一些牢骚 [VS2005]做了两个Code Expansion用的Code Snippet。 VC2005中依然没有Refactoring和Code Expansion. [C++/CLI]在栈上声明Reference Type [C++/CLI] 析构函数等于IDisposable::Dispose()方法 用80386汇编来编写asp.net页面。 关于C#泛型中的new()约束
[VS2005 Tip]定制Code Expansion。
Justin Shen · 2004-10-27 · via 博客园 - Justin Shen

上篇文章里,我向大家介绍了在VS2005的IDE中,利用code expansion功能,自动生成Property的方法,事实上,在VS2005里已经预制了相当多的用来代码扩展(Code Expansion)的代码片断(Code Snippet),"prop"就是一个例子。在Tools菜单下,有一个叫作Code Snippets Manager的工具,在里面可以看到预定义的所有的Code Snippet。

那么我们是不是可以自定义一个Code Snippet用来作Code Expansion呢?经过试验,答案是肯定的!下面我们来看一下怎么完成这个工作。

首先,每个Code Snippet都对应了一个XML文件。在Code Snippets Manager中,我们可以看到这些XML的存放地点。如图:

打开这个XML文件,可以看到如下的内容:


我来解释一下其中主要的标签的作用:

<Shortcut>prop</Shortcut> 

定义了用来扩展的缩写是prop

定义了这个Snippet是用来作Code Expansion的。SnippetType的可能的取值还有

<SnippetType>SurroundsWith</SnippetType> 

你猜得没错这个就是用来设置Intellisense中的Surround With的功能的。一个Snippet可以同时拥有这两个类型。

<Declarations>标签中定义了扩展之后,需要用户填写的部分。每个<Literal>标签定义一个变量。<Default>定义了默认的取值。

最重要的就是<Code>中的内容了,这个就是扩展后的样子了。

下面我写了一个用来自动扩展出一个NUnit的TestFixture的Code Snippet。

注意在这里,我在<Code>中使用了$end$这个预设的变量,这个变量表明了在输入完所有的Literal之后,光标将停留的位置。

写完了之后,将这个XML文件保存到一个新建的目录。然后在Code Snippets Manager中,加入这个目录,然后就可以在IDE中使用这个Code Snippet了。

现在,按下tstFix之后按Tab键,就会自动生成一个带有[TestFixture]属性的类了。

大家还可以按照这个方法去试一下Surround With的功能。