开发者

Can i generate a class automatically on method call?

I have creat开发者_开发百科ed an extended method for DataTable. I want to generate a class automatically in my solution when i call that method while writing a code as Visual studio does when it doesnt find the method. e.g mytable.mymethod(); Generate a class

Is there any way i can achieve this?


There are two ways to dynamically create a class:

Reflection.Emit and CodeDom.

Second one is not recommended because it will create a new assembly and load it which can cause Memory-Leak-like problems.

You can also achieve some of the features using dymanic.


You'd have to write a Visual Studio plugin, detect when you've used a method that doesn't exist and generated it. Or use an existing plugin like ReSharper which will make it easier to generate the method you're calling.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜