Separating Concerns in DynamicProxies

I just finished adding a small but nice feature to DynamicProxies. Now you can use the ProxyBuilder class to pre-bake proxy classes. The key aspect of this feature is that it allows a client to put all of the proxy classes into one assembly. Before, every time you made a proxy, a new assembly was created (this is just the way it is with dynamic code in System.Reflection.Emit). Now, if you a group of types are going to be proxied, you can do the proxy class generation as an initialization step, and only one dynamic assembly will be created. This may seem like an odd feature, but separating the generation of the proxy types from their instantiations is a much cleaner implementation. To the client, the API looks the same, but now there's more options available, and it's easier for me to maintain and add features in the future.

I've also made some other code and API refactoring. Now the Create() method is an extension method for the object type, so you can now write code like this:

var customer = new Customer().Create(this);

Assuming, of course, that the current object implements IInvocationHandler.

Get the latest code drop and check it out.

* Posted at 09.27.2008 04:28:54 PM CST | Link *

Blog History