Visual Studio的代码片段:如何在其中添加逻辑?

JiB*_*evé 6 c# visual-studio-2010

我已经制作了一个小代码片段来为WPF数据绑定创建一个属性:

private string property;
public string Property
{
    get { return this.property; }
    set
    {
        this.property = value;
        this.OnPropertyChanged(() => Property);
    }
}
Run Code Online (Sandbox Code Playgroud)

在Camel Case中创建字段名称并在Pascal Case中重写属性非常麻烦.有没有办法只写字段,让片段使用字母的名称写入属性,第一个字符是大写?

tho*_*ill 8

遗憾的是,Visual Studio代码段功能中没有此类逻辑.必须输入两个名字是你能做的最好的.

以下是创建代码段时可用的唯一"功能". MSDN代码段功能

像Resharper这样的产品提供了出色的代码片段(在Resharper中称为模板)功能,能够在片段中更改其他替换的大小,以及许多其他有用的功能. Resharper模板信息

例如,您会对此宏感兴趣:

"另一个变量的值,第一个字符为小写"