A substitute for ExpandoObject in .NET 3.5 with least overhead
Asked Answered
T

1

6

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.

Triable answered 9/2, 2011 at 21:27 Comment(0)
P
0

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.

Pose answered 29/7, 2012 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.