ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

3.2 Dependencies of the Projects in the Solution 解决方案中项目间的依赖项

2021-10-18 10:31:18  阅读:262  来源: 互联网

标签:Web Domain Contracts Solution Application depends Dependencies 3.2 Shared


3.2 Dependencies of the Projects in the Solution 解决方案中项目间的依赖项

The diagram below shows the essential dependencies (project references) between the projects in the solution (IssueTracking.part is not shown to be simple)
解决方案中各项目之间的基本依赖关系(项目引用关系)(为了简化IssueTracking.部分没有显示):
image
The projects have been explained before. Now, we can explain the reasons of the dependencies;
前面我们已经解释过这些项目。现在,我们可以解释这些依赖项的原因。

  • Domain.Shared is the project that all other projects directly or indirectly depend on. So, all the types in this project are available to all projects.
  • Domain.Shared是所有其他项目直接或间接依赖的项目。所以,这个项目中的所有类型对所有项目都可用。
  • Domain only depends on the Domain.Shared because it is already a (shared) part of the domain. For example, an IssueType enum in the Domain.Shared can be used by an Issue entity in the Domain project.
  • Domain只依赖于Domain.Shared,因为它已经是Domain的一个(共享)部分。例如,Domain.Shared中的枚举类型IssueType可以被Domain项目中的Issue实体使用。
  • Application.Contracts depends on the Domain.Shared. In this way, you can reuse these types in the DTOs. For example, the same IssueType enum in the Domain.Shared can be used by a CreateIssueDto as a property.
  • Application.Contracts依赖于Domain.Shared。通过这种方式,你可以在DTO中重用这些类型。例如,Domain.Shared中的同一个IssueType枚举可以被CreateIssueDto作为一个属性使用。
  • Application depends on the Application.Contracts since it implements the Application Service interfaces and uses the DTOs inside it. It also depends on the Domain since the Application Services are implemented using the Domain Objects defined inside it.
  • Application依赖于Application.Contracts,因为它实现了应用服务接口并使用其中的DTO。它也依赖于Domain,因为应用层服务是通过它里面定义的Domain对象实现的。
  • EntityFrameworkCore depends on the Domain since it maps the Domain Objects (entities and value types) to database tables (as it is an ORM) and implements the repository interfaces defined in the Domain.
  • EntityFrameworkCore依赖于Domain,因为它将领域对象(实体和值类型)映射到数据库表(因为它是一个ORM)并实现Domain中定义的存储库接口。
  • HttpApi depends on the Application.Contracts since the Controllers inside it inject and use the Application Service interfaces as explained before.
  • HttpApi依赖于Application.Contracts,因为它里面的控制器注入并使用应用服务接口,前面已解释说明过。
  • HttpApi.Client depends on the Application.Contracts since it can consume the Application Services as explained before.
  • HttpApi.Client依赖于Application.Contracts,因为它可以使用应用服务,前面已解释说明过。
  • Web depends on the HttpApi since it serves the HTTP APIs defined inside it. Also, in this way, it indirectly depends on the Application.Contracts project to consume the Application Services in the Pages/Components.
  • Web依赖于HttpApi,因为它提供了在它里面定义的HTTP APIs。另外,通过这种方式,它间接地依赖于Application.Contracts项目运用于页面/组件中的应用服务。

Dashed Dependencies 隐含的依赖项

When you investigate the solution, you will see two more dependencies shown with the dashed lines in the figure above. Web project depends on the Application and EntityFrameworkCore projects which theoretically should not be like that but actually it is.
当你调查这个解决方案时,你会看到还有两个依赖关系,在上图中用虚线表示。Web项目依赖于Application项目和EntityFrameworkCore项目,理论上不应该是这样,但实际上是这样。
This is because the Web is the final project that runs and hosts the application and the application needs the implementations of the Application Services and the Repositories while running.
这是因为 Web项目是运行和托管应用程序的最终项目,应用程序在运行时需要应用服务和存储库的实现
This design decision potentially allows you to use Entities and EF Core objects in the Presentation Layer which should be strictly avoided. However, we find the alternative designs over complicated. Here, two of the alternatives if you want to remove this dependency;
这个设计决定有可能让你在表现层中使用实体和EF核心对象,这应该是严格避免的。然而,我们发现替代设计过于复杂。在这里,如果你想消除这种依赖关系,有两个备选方案:

  • Convert Web project to a razor class library and create a new project, like Web.Host, that depends on the Web,Application and EntityFrameworkCore projects and hosts the application. You don't write any UI code here, but use only for hosting.
  • 将Web项目转换为Razor类库,并创建一个新的项目,如Web.Host,它依赖于Web,ApplicationEntityFrameworkCore项目并托管这个应用程序。你不在这里写任何UI代码,而只用于托管
  • Remove Application and EntityFrameworkCore dependencies from the Web project and load their assemblies on application initialization. You can use ABP's Plug-In Modules system for that purpose.
  • Web项目中移除ApplicationEntityFrameworkCore依赖,并在应用程序初始化时加载它们的程序集。你可以使用ABP的插件模块系统达到此目的。

标签:Web,Domain,Contracts,Solution,Application,depends,Dependencies,3.2,Shared
来源: https://www.cnblogs.com/tjubuntu/p/15419478.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有