I have a WCF service that I'm trying to resolve using Castle Windsor. The registration used to look like this:
container.Register(Component.For<IBatchDataService>()
.AsWcfClient(WCFEndpoint
.FromConfiguration("Internal.IBatchDataService"))
.LifestyeTransient())
Now I've created a proxy that lives in process. It exposes the same interface (IBatchDataService) and takes a reference to the WCF service as a constructor argument. How do I set up this up in Windsor so that any other classes get resolved to use the proxy class but the proxy class resolves to the WCF service. I have this right now:
container.Register(Component.For<IBatchDataService>()
.ImplementedBy<BatchDataServiceClient>());
which should resolve the new proxy class.
Try this:
container.Register(
Component.For<IBatchDataService>().AsWcfClient(WCFEndpoint.FromConfiguration("Internal.IBatchDataService")).LifestyeTransient().Named("wcfBatchDataService"),
Component.For<IBatchDataService>().ImplementedBy<BatchDataServiceClient>().AsDefault().DependsOn(
Dependency.OnComponent("constructorParameterName", "wcfBatchDataService")
)
Where constructorParameterName is the name of the IBatchDataService parameter on your constructor. I've not run it in a compiler so please let me know if this works for you.
Kind regards, Marwijn.