开发者

Wcf dependency injection

I have an IService.

It is implemented by Service1.

I bind IService 开发者_开发问答to Service1 (im using ninject).

Can I have a .svc file that in the markup has...

Service="IService"

And tell wcf to somehow resolve that service and use it?


No, the .svc file is bound to the service type. What you can have is a route (if you use the ASP.NET Routes integration) where you, in code, resolve the IService binding to Service1 and add the route accordingly.


in the .svc file you can set Factory= to the class that you want to resolve the service. I have not tried setting Service to an interface. If it does not work you can use an abstract base class for your IOC.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜