(This documentation is written just to cover the essentials for now, at some point I will revise what I've written to make it sound better and friendlier to the reader.)

EasyProxy is supposed to make your life as a .NET developer easier when working with WCF proxies.


Why EasyProxy? It was born out of the need for WCF to be more IOC friendly. You can wrap your current channel factories in classes and let an IOC container give you an instance but it generally ends up that you create a channel and close it after every use and that is very inefficient, especially if you have the more secure WS* connections.
Also generally your code is filled with logic for handling channels and it clutters up your codebase pretty quickly. Also, you are never fully separated from WCF in your code.

What EasyProxy provides

EasyProxy is by no means feature complete and ready to infiltrate the WCF society completely, but it is my attempt at starting something that would hopefully give people something to work from.
EasyProxy currently provides the following features:
  • IOC friendly injection - no WCF logic in your business logic!
  • No need to generate or create your own proxies, it uses the WCF Channel Factory
  • Channel pools - for times when you need that channel to be available and ready on slow to create connections (needs to be configured to use it)
  • Extensible & configurable - change the behavior of your proxy by supplying a different call behavior, channel allocator or channel factory.

Let's look at some code before we continue with the other bits.

Here is an example of creating a proxy for immediate use:
IMyContract proxy = EasyProxyFactory.CreateProxy<IMyContract>();


You don't have to call that over and over, you can reuse that 'proxy' instance. In fact, you can even do something like this:

private static IMyContract proxy = EasyProxyFactory.CreateProxy<IMyContract>();

Not that it is good coding practice but it gives you an idea of its usage. Now you can hook this up in your favourite IOC container.

// Using something like Ninject you can do something like this:

kernel.Bind<IMyContract>.ToMethod(context => EasyProxyFactory.CreateProxy<IMyContract>()).InSingletonScope();

Here are the various sections of EasyProxy that will be further explained:

Last edited Jun 4, 2013 at 4:07 PM by dandrejvv, version 7


No comments yet.