Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Framework for .net Reflection.Emit simplification?

Is there a framework, that makes the use of of Reflection.Emit easier? Something I can tell: Give me a class with a string field and get,set accessors.

The code I find in Create a class type in code in .net c# is what I need, but it is somewhat cryptic. I think a library with a simplified interface would boost productivity.

like image 231
Frank Michael Kraft Avatar asked Aug 02 '10 08:08

Frank Michael Kraft


2 Answers

I think you just described CodeDOM. Unfortunately, it doesn't really (IMO) make it easier - it just makes it... different.

Personally, I'd just use TypeBuilder, ILGenerator and encapsulate the common functionality I need, i.e.

PropertyBuilder CreateProperty(TypeBuilder type, string name, Type propertyType)
{...}

Meta-programming is rarely simple, but from that detail you get a very good understanding of what is actually happening.

like image 79
Marc Gravell Avatar answered Oct 20 '22 02:10

Marc Gravell


Have a look at the CCI.

like image 21
leppie Avatar answered Oct 20 '22 03:10

leppie