RemotingPolicyInjector extension points

Topics: Development Team Discussion
Coordinator
Aug 16, 2007 at 2:34 PM
In DoWrap(...), it the creation of the proxy was extracted in a Factory method, it would ease extension of the RemotingPolicyInjector class

protected override object DoWrap(object instance, Type typeToReturn, PolicySet policiesForThisType)
{
if (PolicyRequiresInterception(policiesForThisType))
{
InterceptingRealProxy proxy = CreateProxy(UnwrapTarget(instance), typeToReturn, policiesForThisType);
return proxy.GetTransparentProxy();
}
return instance;
}

protected virtual InterceptingRealProxy CreateProxy(object target, Type typeToReturn, PolicySet policiesForThisType)
{
return new InterceptingRealProxy(target, typeToReturn, policiesForThisType);
}

public class CustomInterceptingRealProxy : InterceptingRealProxy { ... }
public class CustomRemotingInjector : RemotingPolicyInjector
{
protected override InterceptingRealProxy CreateProxy(...) { return new CustomInterceptinRealProxy(...); }
}