问题描述
当我们选择 Refactoring, Encapsulate Fields for let's say:
When one choose Refactoring, Encapsulate Fields for let's say:
int m_member;
VS 会生成
public int Member
{
get { return m_member; }
set { m_member = value; }
}
出于某种原因(例如使用不知道这种风格的逆向工程工具),我想获得更古老和更冗长的风格:
For some reason (using a reverse engineerint tool for example which doesn't know this style), I'd like to get the oldish and more verbose style:
public int getMember() {
return m_member;
}
public void setMember(int value) {
m_member = value;
}
是否可以将 VS 配置为这样做?否则,如果有必要,还有其他任何方式使用示例代码,例如创建代码片段模板甚至插件吗?
Is it possible to configure VS to do so ? Otherwise any other mean with sample code like creating snippet template or even Plugin if necessary ?
推荐答案
虽然我不一定推荐这样做,但所有重构都只是您可以编辑的片段.默认安装会将 C# 模板放在此文件夹中,C:\Program Files\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Refactoring
,只需找到您想要的并根据需要进行修改看合适.
Although I don't necessarily recommend this, all refactorings are simply snippets that you can edit. A default installation will put the C# templates in this folder, C:\Program Files\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Refactoring
, simply find the one that you want and modify as you see fit.
注意:一定要先备份!!
NOTE: Be sure to take a backup first!!
我也同意其他人的看法,这是一个非常糟糕的主意!
I'll also agree with everyone else, that this is a REALLY bad idea!
这篇关于字段封装的不同重构风格:如何让Visual Studio改变它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!