编写代码模板时是否可以使用反射?
我只是在想是否有可能编写一段代码模板,它将返回我在 Visual Studio 中由 && 运算符分隔的类中所有私有字段的列表?
比方说,我将在 VS 编辑器中输入“getAllPrivates&&”(或按快捷键),它会返回如下内容:
private bool _privateFiel1 = false;
private bool _privateFiel2 = true;
private bool _privateFiel3 = false;
private bool _privateFiel4 = false;
private bool _privateFiel5 = true;
// Here I press the shortcut or call the code-template and get his:
_privateFiel1 && _privateFiel2 && _privateFiel3 && _privateFiel4 && _privateFiel5