问题描述:

Is it by design to prevent changing the proxy target for concrete types? If so, why?

Background:

I have a concrete class that I want to proxy. Further, I want to replace the target of the proxy at some point in the workflow. I've attempted to use IChangeProxyTarget in order to change the proxy target, however, this doesn't seem possible given that the InheritanceInvocationTypeGenerator which is created for IInvocation instances generated on classes always passes false to the canChangeTarget parameter on the InvocationTypeGenerator base constructor.

I believe I can replace enough of the generator lookup machinery in the driving IProxyBuilder to get this value to be true (and, indeed, forcing the value to be true in the debugger generates an IInvocation type which implements IChangeProxyTarget), however, I'm wondering why this is not more easily accessible.

网友答案:

The short answer is, it's not there because it hasn't been implemented. From the top of my head I don't see any reason not to do it.

相关阅读:
Top