我厌倦了编写锅炉板属性代码,例如:
public string Name
{
get { return this.name; }
set { SetProperty(ref name, value); }
}
所以我决定在Visual Studio中创建一个代码片段来自动化该过程:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>MVVM Property</Title>
<Shortcut>propm</Shortcut>
<Author>MFeinstein</Author>
<Description>Adds a Property that calls PRISM no Notify any changes</Description>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Replace with the property type</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>PropertyName</ID>
<ToolTip>Replace with the property name</ToolTip>
<Default>propertyName</Default>
</Literal>
<Literal>
<ID>fieldName</ID>
<ToolTip>Replace with the field name</ToolTip>
<Default>fieldName</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[private $type$ $fieldName$;
public $type$ $PropertyName$
{
get { return this.$fieldName$; }
set { SetProperty(ref $fieldName$, value); }
}$selected$ $end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
问题是,我想只输入一次名称,并将其命名为&#34; name&#34;在该领域和作为&#34;姓名&#34;在属性中,大写。此外,我想在课程开始时自动对支持字段进行分组,正如良好实践所推荐的那样。
有谁知道怎么做?
答案 0 :(得分:-1)
我无法评论,所以我会回答。怎么样:
public string Name { get; set; }
您没有支持变量,可以在<type,name>
对