编写VS的Snippet

参考:https://www.cnblogs.com/actberw/archive/2010/04/09/1708395.html(vs中的code snippet技术)

 

步骤1:写代码

<?xml version ="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Property Of ViewModel</Title>
<Shortcut>vmp</Shortcut>
<Description>Property Of ViewModel</Description>
<Author>soeasy</Author>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>DataType</ID>
<ToolTip>data type of the property</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>PropertyName</ID>
<ToolTip>property name</ToolTip>
<Default>Prop1</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[
#region $PropertyName$
$DataType$ _$PropertyName$;
public $DataType$ $PropertyName$
{
get{
return _$PropertyName$;
}
set{
SetProperty(ref _$PropertyName$,value);
}
}
#endregion
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

步骤2:存成 soeasy.snippet

步骤3:vs>工具>代码片断管理器,导入,选择 My Code Snippet

文件会存放在 C:\Users\cqsir\Documents\Visual Studio 2017\Code Snippets\Visual C#\My Code Snippets

疑问:不懂为什么,在代码片断管理器里,选中My Code Snippet时,没有显示预览。但是实际上这个snippet是可用的。

转载于:https://www.cnblogs.com/erentec/p/11064617.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值