开发者

What is the primary purpose of the NinjectServiceHost class?

At first I thought using NinjectServiceHost class was the only way to create, for example, a non-default service implementation class instance. (Out of the box you can only call new ServiceHost(typeof(SomeClass)), where SomeClass would be instantiated using a parameterless constructor, which doesn't allow any dependency injection).

But now I see that I can simple use Ninject kernel to retrieve a singleton instances of easily testable classes (that don't implement singleton explicitly, rather I would use InSingletonScope binding of Ninject) from within my service class.

What is the main use of NinjectServiceHost? What featur开发者_运维知识库es does it provide?


The answer apears to be the following:

If I don't use a NinjectServiceHost to host a WCF service, my service class would have to be Ninject-aware to resolve it's dependencies in code.

Using NinjectServiceHost allows to pass a constructor parameters to a service class, thus allowing it to be independent of Ninject.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜