To create a proxy for an interface (or a class that implements MashalByRefObject).
public class Proxy : RealProxy
{
MarshalByRefObject _instance;
private Proxy(MarshalByRefObject instance)
: base(instance.GetType())
{
_instance = instance;
}
public static T CreateProxy<T>(MarshalByRefObject instance)
where T : MarshalByRefObject
{
return new Proxy(instance).GetTransparentProxy() as T;
}
public override IMessage Invoke(IMessage msg)
{
IMethodCallMessage message = msg as IMethodCallMessage;
//TODO Implement proxy functionality here
return RemotingServices.ExecuteMessage(_instance, msg as IMethodCallMessage);
}
}