A substitute for ExpandoObject in .NET 3.5 with least overhead

2.6k views Asked by At

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.

1

There are 1 answers

0
Colin Smith On

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.