Paul Knopf
Paul Knopf

Reputation: 9776

WCF with interfaces as parameters

Please don't respond with ServiceKnownType, as I don't know what the concrete implementation will be.

The interface is designed to be created from an ioc container. I created a ServiceHostFactory that adds a IInstanceProvider that grabs the service from the container.

What I want know is to be able to add IInstanceProviders to the client side calls for the parameters.

    var factory = new WebChannelFactory<ITestService>(new Uri("http://localhost:30646/TestService.svc"));
    var service = factory.CreateChannel();
    var result = service.TestMethod("sdf");

This is how I am creating proxy on the client side. Imagine I have a return type as ICustomType.

Is there a way I can tell the factory above to use a certain instance provider with trying to create interfaces? That way, I can call my container for the instance.

Upvotes: 0

Views: 160

Answers (1)

Richard Blewett
Richard Blewett

Reputation: 6109

There is no IInstanceProvider model on the client side - it is for creating the services instances when they are required.

You could derive from ChannelFactory and do your IoC resolution in there

btw: You do know that ServiceKnownType can take a method rather than a type which can return the valid known types at runtime?

Upvotes: 1

Related Questions