三、Implementation: The Big Picture 实现:蓝图

3.1 Layering of a .NET Solution .Net解决方案的分层

The picture below shows a Visual Studio Solution created using the ABP's application startup template:

使用ABP的应用程序启动模板创建的Visual Studio解决方案,如下图所示:



The solution name is IssueTracking and it consists of multiple projects. The solution is layered by considering DDD principles as well as development and deployment practicals. The sub sections below explains the projects in the solution;

该解决方案的名称叫IssueTracking,它由多个项目组成。该解决方案分层时充分考虑DDD原则以及开发和部署的实际情况。下面的小节对解决方案中的各个项目进行解释。

Your solution structure may be slightly different if you choose a different UI or Database provider. However, the Domain and Application layers will be same and this is the essential point for the DDD perspective. See the Application Startup Template document if you want to know more about the solution structure.

如果你选择不同的UI或数据库,你的解决方案结构可能会略有不同。然而,领域层和应用层是一样的,并且这是DDD的关键点。如果你想了解更多关于解决方案结构的信息,请参阅应用程序启动模板的说明文档。

3.1.1 The Domain Layer 领域层

The Domain Layer is splitted into two projects;

领域层分为两个项目:

  • IssueTracking.Domain is the essential domain layer that contains all the building blocks (entities, value objects,domain services, specifications, repository interfaces, etc.)introduced before.

  • IssueTracking.Domain是领域层,包含了之前介绍的所有构件(实体、值对象、领域服务、规范、资源库接口等)。

  • IssueTracking.Domain.Shared is a thin project that contains some types those belong to the Domain Layer,but shared with all other layers. For example, it may contain some constants and enums related to the Domain Objects but need to be reused by other layers.

  • IssueTracking.Domain.Shared是一个单薄的项目,它包含一些领域层的类型,并与所有其他层共享。例如,它可能包含一些与领域对象相关的常量和枚举,需要被其他层重用。

3.1.2 The Application Layer 应用层

The Application Layer is also splitted into two projects;

应用层也分为两个项目:

  • IssueTracking.Application.Contracts contains the application service interfaces and the DTOs used by these interfaces. This project can be shared by the client applications (including the UI).
  • IssueTracking.Application.Contracts包含应用服务的接口和这些接口所使用的DTO。这个项目可以被客户端应用程序(包括UI)使用。
  • IssueTracking.Application is the essential application layer that implements the interfaces defined in the Contracts project.
  • IssueTracking.Application 是重要的应用层,它实现了IssueTracking.Application.Contracts项目中定义的接口。

3.1.3 The Presentation Layer 展现成

  • IssueTracking.Web is an ASP.NET Core MVC / Razor Pages application for this example. This is the only executable application that serves the application and the APIs.
  • IssueTracking.Web是本例的ASP.NET Core MVC / Razor Pages应用程序。这是唯一的可执行应用程序,为应用程序和API服务。

    ABP Framework also supports different kind of UI frameworks including Angular and Blazor. In these cases, the IssueTracking.Web doesn't exist in the solution. Instead, an IssueTracking.HttpApi.Host application will be in the solution to serve the HTTP APIs as a standalone endpoint to be consumed by the UI applications via HTTP API calls.

    ABP框架也支持不同类型的UI框架,包括Angular和Blazor。在这种情况下,解决方案中就不存在IssueTracking.Web项目。反而,IssueTracking.HttpApi.Host应用程序将在解决方案中作为一个独立的终端为HTTP API提供服务,通过HTTP API调用被UI应用程序所使用。

3.1.4 The Remote Service Layer 远程服务层

  • IssueTracking.HttpApi project contains HTTP APIs defined by the solution. It typically contains MVC Controllers and related models, if available. So, you write your HTTP APIs in this project.
  • IssueTracking.HttpApi项目包含解决方案中定义的HTTP APIs。它通常包含MVC控制器和相关模型(如果有的话)。所以,你在这个项目中编写你的HTTP APIs。

    Most of the time, API Controllers are just wrappers around the Application Services to expose them to the remote clients. Since ABP Framework's Automatic API Controller System automatically configures and exposes your Application Services as API Controllers, you typically don't create Controllers in this project. However, the startup solution includes it for the cases you need to manually create API controllers.

    大多数时候,API控制器只是应用服务的包装,将它们暴露给远程客户端。由于ABP框架的自动API控制器系统可以自动配置并将你的应用服务作为API控制器暴露出来,你通常不用在这个项目中创建控制器。然而,启动方案包括它是为了满足你需要手动创建API控制器的情况。
  • IssueTracking.HttpApi.Client project is useful when you have a C# application that needs to consume your HTTP APIs. Once the client application references this project, it can directly inject & use the Application Services. This is possible by the help of the ABP Framework's Dynamic C# Client API Proxies System.
  • IssueTracking.HttpApi.Client 当你有一个C#应用程序需要使用你的HTTP APIs时,IssueTracking.HttpApi.Client项目是非常有用的。一旦客户端应用程序引用了这个项目,它就可以直接注入和使用这些应用服务。通过ABP框架的C#客户端API动态代理系统的帮助这是可能的。

    There is a Console Application in the test folder of the solution,named IssueTracking.HttpApi.Client.ConsoleTestApp. It simply uses the IssueTracking.HttpApi.Client project to consume the APIs exposed by the application. It is just a demo application and you can safely delete it. You can even delete the IssueTracking.HttpApi.Client project if you think that you don't need to them.

    在解决方案的test文件夹中有一个控制台应用程序,叫IssueTracking.HttpApi.Client.ConsoleTestApp。它只是使用应用程序IssueTracking.HttpApi.Client项目所暴露的API。它只是一个演示应用程序,你可以安全地删除它。如果你认为不需要,你甚至可以删除IssueTracking.HttpApi.Client项目。

3.1.5 The Infrastructure Layer 基础设施层

In a DDD implementation, you may have a single Infrastructure project to implement all the abstractions and integrations, or you may have different projects for each dependency.

在DDD的实施中,你可能有一个单独的基础设施项目来实现所有的抽象和集成,或者你可能为每个依赖创建不同的项目。

We suggest a balanced approach; Create separate projects for main infrastructure dependencies (like Entity Framework Core) and a common infrastructure project for other infrastructure.

我们建议采取一种平衡的方法;为主要的基础设施依赖(如Entity Framework Core)创建单独的项目,为其他基础设施创建一个公共的基础设施项目。

ABP's startup solution has two projects for the Entity Framework Core integration;

ABP的启动方案有两个项目用于Entity Framework Core的集成:

  • IssueTracking.EntityFrameworkCore is the essential integration package for the EF Core. Your application's DbContext, database mappings, mplementations of the repositories and other EF Core related stuff are located here.
  • IssueTracking.EntityFrameworkCore 是EF Core的基本集成包。应用程序的DbContext、数据库映射、资源库的实现和其他EF Core相关的东西都放在这里。
  • IssueTracking.EntityFrameworkCore.DbMigrations is a special project to manage the Code First database migrations. There is a separate DbContext in this project to track the migrations. You typically don't touch this project much except you need to create a new database migration or add an application module that has some database tables and naturally requires to create a new database migration.
  • IssueTracking.EntityFrameworkCore.DbMigrations 是一个特殊的项目,用于管理Code First模式的数据库的迁移。在这个项目中,有一个单独的DbContext来跟踪迁移。除非你需要创建一个新的数据库迁移,或者添加一个已经存在数据库表的应用程序模块,这当然需要创建一个新的数据库迁移,否则你通常不要动这个项目。

    You may wonder why there are two projects for the EF Core. It is mostly related to modularity. Each module has its own independent DbContext and your application has also one DbContext. DbMigrations project contains a union of the modules to track and apply a single migration path. While most of the time you don't need to know it, you can see the EF Core migrations document for more information.

    你可能想知道为什么EF Core有两个项目。这主要是与模块化有关。每个模块都有自己单独的DbContext,你的应用程序也有一个DbContext。DbMigrations项目包含了各模块的联合,以跟踪和运用单一的迁移路径。虽然大多数时候你不需要了解它,但你可以查看EF Core迁移文档以了解更多信息。

3.1.6 Other Projects 其它项目

There is one more project, IssueTracking.DbMigrator, that is a simple Console Application that migrates the database schema and seeds the initial data when you execute it. It is a useful utility application that you can use it in development as well as in production environment.

还有一个项目,IssueTracking.DbMigrator,它是一个简单的控制台应用程序,当你执行它时,它会同步数据库结构并产生初始化数据。这是一个有用的工具程序,你可以在开发环境和生产环境中使用它。

3 Implementation: The Big Picture 实现:蓝图的更多相关文章

  1. (翻译)领域驱动设计实现-Implementing Domain Driven Design

    简介 Implementing Domain Driven Design 领域驱动设计实现 A practical guide for implementing the Domain Driven D ...

  2. Atitit.研发管理---TOGAF架构跟 (ADM开发方法)总结

    Atitit.研发管理---TOGAF架构跟 (ADM开发方法)总结 1. TOGAF是在过去二十年间出现的企业架构框架 1 2. TOGAF内容结构 1 3. TOGAF 实现过程 2 4. 参考 ...

  3. Build Telemetry for Distributed Services之OpenTracing简介

    官网地址:https://opentracing.io/ What is Distributed Tracing? Who Uses Distributed Tracing? What is Open ...

  4. 介绍Unreal Engine 4中的接口(Interface)使用C++和蓝图

    这个教程是从UE4 Wiki上整理而来. 在C++中直接使用Interface大家应该很熟悉.只是简单先定义一个个有虚函数的基类,然后在子类中实现相应的虚函数.像这样的虚函数的基类一般概念上叫接口.那 ...

  5. IMS Global Learning Tools Interoperability™ Implementation Guide

    Final Version 1.1 Date Issued:            13 March 2012 Latest version:         http://www.imsglobal ...

  6. [译]Ocelot - Big Picture

    原文 目录 Big Picture Getting Started Configuration Routing Request Aggregation Service Discovery Authen ...

  7. 第九篇 蓝图 blueprint

    在Flask中的蓝图 blueprint 的作用就是将 功能 与 主服务 分开 比如说,你有一个客户管理系统,最开始的时候,只有一个查看客户列表的功能,后来你又加入了一个添加客户的功能(add_use ...

  8. [转]An overview of Openvswitch implementation

    This is NOT a tutorial on how to use openvswitch, this is for developers who want to know the implem ...

  9. UE4修改自Rama的UDP通信蓝图插件

    UE4.15没有提供蓝图UDP的组件,可以在网上找到一个ID叫Rama写的源代码,我把它封装成插件了(MyUdpPlugin),方便在各个UE4版本工程中使用UDP通信. 使用方式: 1.在自己的工程 ...

随机推荐

  1. Charles-模拟弱网环境

    在做弱网测试时,经常需要模拟各种网络环境,Charles恰好也提供了网络限制的功能,我们可以在"Proxy->Throttle Settings"路径下找到它,如下图所示. ...

  2. JS006. 详解自执行函数原理与数据类型的快速转换 (声明语句、表达式、运算符剖析)

    今天的主角: Operator Description 一元正值符 " + "(MDN) 一元运算符, 如果操作数在之前不是number,试图将其转换为number. 圆括号运算符 ...

  3. css对角渐变

    html: <div class="hh"> </div> css: .hh{ width: 500px; height: 500px; backgroun ...

  4. 菜狗、《灵笼》、《时光代理人》,重新审视Z世代的电商逻辑

    来源:懂懂笔记 B站还有多少潜力可以挖掘? 虽然B站的最新财报依然还是亏损,但同时也让人看到更多的可能性. 从财报数据的亮点来看,一是营收增长,B站二季度营收为44.95亿元,同比增长72%.营收上B ...

  5. vue 动态ip配置,避免重复打包

    目前比较流行的打包大都是在vue.config.js配置代理,然后在根目录新建.env.xxx文件配置正式环境,测试环境,开发环境等用于打包时配置不同的访问地址,作为一名随波逐流的前端开发,我也是这么 ...

  6. Go并发编程--正确使用goroutine

    目录 1. 对创建的gorouting负载 1.1 不要创建一个你不知道何时退出的 goroutine 1.1.1 不要帮别人做选择 1.1.2 不要作为一个旁观者 1.1.3 不要创建不知道什么时候 ...

  7. 洛谷P1208——P1208 [USACO1.3]Mixing Milk(贪心)

    题目描述 由于乳制品产业利润很低,所以降低原材料(牛奶)价格就变得十分重要.帮助Marry乳业找到最优的牛奶采购方案. Marry乳业从一些奶农手中采购牛奶,并且每一位奶农为乳制品加工企业提供的价格是 ...

  8. math.h库详解

    sin(double) cos(double) tan(double) 分别返回正弦,余弦,正切 #include<iostream> #include<math.h> usi ...

  9. 【PHP数据结构】链表的相关逻辑操作

    链表的操作相对顺序表(数组)来说就复杂了许多.因为 PHP 确实已经为我们解决了很多数组操作上的问题,所以我们可以很方便的操作数组,也就不用为数组定义很多的逻辑操作.比如在 C 中,数组是有长度限制的 ...

  10. dede编辑文章不更新时间的方法

    在修改文章的时候,发现织梦DEDECMS5.7这个版本存在一个问题,修改文章的同时也修改了文章的发布时间,这个 功能可能有些人比较需要,但同时也有些站长朋友又不需要,因为我们编辑某个文章的时候,发现编 ...