How can I imitate the functionality of the ExpandoObject in a .NET 3.5 application with the least overhead? My best lead so far is to use the Lin Fu framework ( http://www.codeproject.com/KB/cs/LinFuPart2.aspx ), but I'm thinking there may be something better.
To give a better idea of what I am going for here, my objective is to dynamically create the type from the parameters of a MethodInfo
. So, basically I want to turn this:
public class ServiceObject
{
public void Execute(string TransformMeIntoAProperty);
}
into
public class ServiceObjectExecuteSignature
{
public string TransformMeIntoAProperty{ get; set;}
}
at runtime. I have to be able to access the Parameters using Reflection, because I am using Linq Expressions.
You could use the CodeDom to dynamically compile some new types at runtime. Obviously there's an upfront cost of doing that....I suppose it depends on the lifetime of the types you are generating.
http://www.codeproject.com/Articles/26312/Dynamic-Code-Integration-with-CodeDom
http://www.c-sharpcorner.com/uploadfile/mgold/codedomcalculator08082005003253am/codedomcalculator.aspx
http://igorshare.wordpress.com/2008/01/11/codedom-extensions-and-dynamic-linq-stringscript-to-linq-emitting/