DDD项目结构,WCF [英] DDD Projects Structure With WCF

查看:157
本文介绍了DDD项目结构,WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始是由一个引擎以及一些桌面应用程序组成一个新的基于WCF的项目。
但我发现它很难让我的项目结构。

I'm starting a new WCF-based project which is composed by an "Engine" and some desktop applications. But i found it difficult to make my project structure.


  • 引擎(Windows服务,该服务主机WCF服务的桌面应用程序的访问,并举办我所有的业务逻辑)

  • 桌面应用程序(仅presentation)

  • Engine (Windows Service, which host WCF Services for Desktop applications access and host all my business logic)
  • Desktop Application (Only Presentation)

共享

MyProject.Core(客户/客户,客户/ ICustomerService)

MyProject.Core (Customers/Customer, Customers/ICustomerService)

引擎


  • MyProject.Engine(客户/的CustomerService,客户/ ICustomer,客户/ ICustomerRepository)

  • MyProject.Infrastructure.SqlServer(客户/客户(LinqToSql具体的),客户/ CustomerRepository)

WinForm应用程序

我说得对?

推荐答案

如果你正在做的DDD我觉得奇怪,你没有域模型。你有一个所谓的发动机,其具有多个关注点。它实现你的业务逻辑和知道托管业务逻辑作为Windows服务。

If you are doing DDD I find it strange that you have no domain model. You have a so-called engine, which has multiple concerns. It implements your business logic and knows about hosting your business logic as a windows service.

我想提出一个项目结构如下:

I would propose a project structure as follows:

MyProject.Model :定义抽象库,实体,值对象,服务(DDD项)等领域逻辑。它有其他项目的引用

MyProject.Model: Defines abstract repositories, entities, value objects, services (DDD term) and other domain logic. It has no references to other projects

MyProject.DataAccess :实现使用LINQ2SQL库。有MyProject.Model参考

MyProject.DataAccess: implementation of repositories using linq2sql. Has a reference to MyProject.Model

MyProject.ServiceModel :包含服务合同和相关的暴露你的域模型作为WCF服务的其他的东西。该项目还将包含针对特定服务重新$那些您的域的对$ psentations对象,服务提供和接受。这样做的原因是,你可能不应该在WCF数据契约所需要的属性装饰你的领域类。该项目引用MyProject.Model。

MyProject.ServiceModel: Contains service contracts and other stuff related exposing your domain model as WCF services. this project would also contain service specific representations of those of your domain objects that the service serves and accepts. The reason for this would be that you should probably not decorate your domain classes with the attributes needed in WCF data contracts. This project references MyProject.Model.

MyProject.Service :包含的app.config为您服务,并执行依赖注入,通过自定义的ServiceHost和ServiceHostFactory。它引用MyProject.Model MyProject.ServiceModel和MyProject.DataAccess +你喜欢的DI框架(温莎城堡为例)

MyProject.Service: Contains app.config for your service and performs dependency injection, through a custom ServiceHost and ServiceHostFactory. It references MyProject.Model MyProject.ServiceModel and MyProject.DataAccess + your favorite DI framework (Windsor Castle for example)

MyProject的presentationModel :定义各种视图模型和命令在UI使用。它由MyProject.Service公开的服务服务引用

MyProject.PresentationModel: Defines various view models and commands to use in your UI. It has service references to the services exposed by MyProject.Service

MyProject.WinUI :您的WPF应用程序。参考MyProject的。presentationModel。

MyProject.WinUI: Your WPF app. References MyProject.PresentationModel.

请注意,大多数的你可能已经在Eric Evans的本书读DDD只关心MyProject.Model的内容。其他项目正在增设层不直接先生处理。埃文斯的书。

Note that most of what you have probably read in Eric Evans' book about DDD is only concerned with the contents of MyProject.Model. The other projects are making up additional layers not directly addressed in mr. Evans' book.

请记住,通过具有一个清晰的关注分离,使用依赖注入,你将结束与code,很容易测试。随着我上面提出的结构,你应该能够测试几乎一切,因为你的UI将只包含XAML。

Remember that by having a clear separation of concerns, and using dependency injection you will end up with code that is easily tested. With the structure I have proposed above, you should be able to test almost everything, since your UI will contain only XAML.

无论如何,这只是我拿就可以了。请随时问一些这方面需要澄清。

Anyway, this is just my take on it. Please feel free to ask if some of this needs clarification.

祝你好运与项目。

/克劳斯

这篇关于DDD项目结构,WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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