DI CompositionRoot多WCF服务主机主机、DI、CompositionRoot、WCF

由网友(为他提剑平丘壑)分享简介:我们正在开发一种将动态加载服务的基础上配置一个selfhosted WCF服务主机。 We are developing a selfhosted WCF service host which will be loading services dynamically based on configuration....

我们正在开发一种将动态加载服务的基础上配置一个selfhosted WCF服务主机。

We are developing a selfhosted WCF service host which will be loading services dynamically based on configuration.

我想知道阉我应该考虑每个服务作为一个小型应用程序,并使用组成的根在每个托管服务或使用组合根服务主机本身?

I was wondering wether I should consider each service as a mini app and use composition root in each hosted service or use composition root on the service host itself?

您输入多少AP preciated!

Your input is much appreciated!

推荐答案

其成分根元的服务是好的,但如果你能,让你的WCF服务只包含1服务有两种方法:一种方法,可以让你执行查询对象,一种方法,可以让你执行命令。这样,您将还有一个成分根为WCF服务。

Having a composition root per service is fine, but if you can, let your WCF service just contain 1 service with 2 methods: One method that allows you to execute query objects, one method that allows you to execute commands. This way you will still have one Composition Root for your WCF service.

要允许这样做,你需要模拟所有突变的命令/ 和读取操作的查询/处理。当你这样做,你将永远不会有以后再改变​​什么的SVC。

To allow to do this you need to model all mutations as commands/handlers and read operations as query/handlers. When you've done this, you will never have to change anything to the SVC ever again.

看看的 Silverlight的食谱,该成功地使用了这种方法。看看在主食谱 Services.Host CommandService.svc的.cs 的,这是WCF服务的入口点。

Take a look at the Silverlight Cookbook, which successfully uses this approach. Take a look at the MainCookbookServices.HostCommandService.svc.cs, which is the entry point of the WCF service.

这将可能把你的世界彻底颠倒了,但是这种结构是非常灵活的,可扩展的,并且可以大大降低维护成本。

This will probably turn your world completely upside down, but this architecture is very flexible, scalable, and can lower the maintenance costs dramatically.

阅读全文

相关推荐

最新文章