以接口作为参数的 WCF
请不要回复 ServiceKnownType,因为我不知道具体的实现是什么。
该接口设计为从 ioc 容器创建。我创建了一个 ServiceHostFactory,它添加了一个从容器中获取服务的 IInstanceProvider。
我想知道的是能够将 IInstanceProviders 添加到参数的客户端调用中。
var factory = new WebChannelFactory<ITestService>(new Uri("http://localhost:30646/TestService.svc"));
var service = factory.CreateChannel();
var result = service.TestMethod("sdf");
这就是我在客户端创建代理的方式。假设我有一个返回类型为 ICustomType。
有没有办法告诉上面的工厂使用某个实例提供程序来尝试创建接口?这样,我就可以为该实例调用我的容器。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
客户端没有 IInstanceProvider 模型 - 它用于在需要时创建服务实例。
您可以从 ChannelFactory 派生并在那里进行 IoC 解析
顺便说一句:您确实知道 ServiceKnownType 可以采用可以在运行时返回有效已知类型的方法而不是类型?
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?