三、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. Qt学习日记篇-Qt中使用Curl和jsonCpp

    1.Qt中安装并使用jsonCPP库 1.1  官网下载.https://sourceforge.net/projects/jsoncpp/    解压文件得到 jsoncpp-src-0.5.0 文 ...

  2. [源码解析] 深度学习流水线并行 PipeDream(3)--- 转换模型

    [源码解析] 深度学习流水线并行 PipeDream(3)--- 转换模型 目录 [源码解析] 深度学习流水线并行 PipeDream(3)--- 转换模型 0x00 摘要 0x01 前言 1.1 改 ...

  3. python打包发布自己的pip项目

    原文链接:https://blog.csdn.net/Liangjun_Feng/article/details/80037315 一.注册pypi账号 网址:https://pypi.org/ 直接 ...

  4. Hamcrest 断言框架

    Hamcrest是一个为了测试为目的,能组合成灵活表达式的匹配器类库.用于编断言的框架,使用这个框架编写断言,提高可读性及开发测试的效率,提供了大量"匹配器"方法,每个匹配器用于执 ...

  5. 硕盟SM-T54| TYPE C转HDMI+VGA+USB3.0+PD3.0四合一多功能扩展坞

    硕盟SM-T54是一款 TYPE C转HDMI+VGA+USB3.0+PD3.0四合一多功能扩展坞,支持四口同时使用,您可以将含有USB 3.1协议的电脑主机,通过此产品连接到具有HDMI或VGA的显 ...

  6. k8s资源管理(基础操作)

    1. 基础 本文实操基于k8s 1.22.1 # 可以查看资源分配情况 kubectl describe node # 全局资源情况查看 kubectl api-resources 1.1 apply ...

  7. ysoserial CommonsColletions1分析

    JAVA安全审计 ysoserial CommonsColletions1分析 前言: 在ysoserial工具中,并没有使用TransformedMap的来触发ChainedTransformer链 ...

  8. 使用zipKin构建NetCore分布式链路跟踪

    本文主要讲解使用ZipKin构建NetCore分布式链路跟踪 场景 因为最近公司业务量增加,而项目也需要增大部署数量,K8S中Pod基本都扩容了一倍,新增了若干物理机,部分物理机网络通信存在问题,导致 ...

  9. python中模块与包

    #模块与包#在实际项目中,代码的行数可能上万,甚至上几十万,不可能在一个页面内完成,需要多个程序员通力写作#张三,李四,王五......每天收集大家的代码做一个版本,类似乐高积木一样,每个人负责一部分 ...

  10. 使用阿里云CDN后,php使用$_SERVER['HTTP_VIA']判断是否是移动端会出错

    使用阿里云CDN后,php使用$_SERVER['HTTP_VIA']判断是否是移动端会出错 if (isset ($_SERVER['HTTP_VIA'])) return stristr($_SE ...