开发者

Shortcut to get all private field names combined with && operator as a generated line of code?

开发者 https://www.devze.com 2022-12-29 20:55 出处:网络
Is it possible to use reflection when we write a code-template? I was just thinking if it is possible to write a piece of code-template that will return me a list of all private field in the class se

Is it possible to use reflection when we write a code-template?

I was just thinking if it is possible to write a piece of code-template that will return me a list of all private field in the class separated by && operator in Visual Stuudio?

Let's say, I will enter "getAllPrivates&&" (or press a shortcut key) in the VS editor and it will return me something like this:

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 && _pri开发者_运维知识库vateFiel2  && _privateFiel3 && _privateFiel4 && _privateFiel5


Its not easy. The people at DevExpress I think basically implemented a compilation process to determine this. I hear the same about resharper. If you can look at using DXCore to do the heavy lifting for you. And Since you can get a free copy of CodeRush Xpress I think this will be all you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号