Recently I have been looking for a way to create proxy objects that reflect the properties of other objects programmatically. However I have been unable to find any information on how to do something like this, I believe it should be possible as I have noticed in EntityFramework performing LINQ operations returns proxy objects with the same properties which can be cast directly to the type that they represent.
Basically I am looking for this same functionality and if anyone could explain how it works I would be greatful.
Pseudo code:
object proxy = GetDynamicProxy(typeof(ProxyType));
So basically I am looking for a way to get an object that represents the ProxyType and a method like GetDynamicProxy to get it.
Thanks,
Alex.
In EF the proxy are generated by dynamically deriving from the entity type and dynamically implementing the code. You need to be looking at dynamically compiled assemblies, types and lambdas. System.Reflection.Emit is your friend (???). Here is a link that should help http://msdn.microsoft.com/en-us/library/3y322t50