DI CompositionRoot多WCF服务主机 [英] DI CompositionRoot with multi service WCF Host

查看:189
本文介绍了DI CompositionRoot多WCF服务主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一种将动态加载服务的基础上配置一个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 Main\Cookbook\Services.Host\CommandService.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.

这篇关于DI CompositionRoot多WCF服务主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆