ASP.NET Boilerplate域层似乎包含非域类 [英] ASP.NET Boilerplate Domain Layer appears to contain non-Domain classes

查看:56
本文介绍了ASP.NET Boilerplate域层似乎包含非域类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近对ASP.Net Boilerplate( https://aspnetboilerplate.com )进行了一些分析.我注意到域层(MyProject.Core)具有以下文件夹(默认情况下创建):

I have recently done some analysis of ASP.Net Boilerplate (https://aspnetboilerplate.com). I have noticed that the domain layer (MyProject.Core) has folders for the following (these are created by default):

    Authorization
    Confirguration
    Editions
    Features
    Identity
    Localization
    MultiTenancy
    etc

为什么要将所有这些内容放入应用程序的域层中?从我所看到的;我相信这些代码大部分应该在应用程序层(也可以是服务层)中找到.

Why would you put all of this in the Domain Layer of an application? From what I can see; I believe most of this code should be found in the Application Layer (which could also be the service layer).

推荐答案

好问题,如果您仅查看文件夹名称.但是我想您没有对文件夹中的源代码进行太多研究.

Good question, if you just look at the folder names. But I suppose you haven't investigated the source code in the folders much.

首先,我并不是说这是最好的解决方案体系结构.我们一直在不断改进它,但我们可能会有缺点.请注意,我们的方法是最佳做法和务实的方法.我将尝试简要地解释一下.

First of all, I don't say it's the best solution architecture. We are constantly improving it and we may have faults. Notice that our approach is a mix of best practices & pragmatic approach. I will try to explain it briefly.

您正在谈论这个项目: https://github.com/aspnetboilerplate/module-zero-core-template/tree/master/aspnet-core/src/AbpCompanyName.AbpProjectName.Core 因此,我们来研究以下文件夹:

You are talking about this project: https://github.com/aspnetboilerplate/module-zero-core-template/tree/master/aspnet-core/src/AbpCompanyName.AbpProjectName.Core So, let's investigate the folders:

它不包含任何本地化逻辑(它是在ABP的框架级完成的.因此,它在基础结构层中).它只是定义了本地化文本.

It does not include any localization logic (it's done in framework level, in ABP. Thus, it's in infrastructure layer). It just defines localization texts.

尽管通常可以轻松地将其移至Web层(Core项目中没有直接依赖项),但我们将其放在Core层中,因为我们认为其他应用程序中也可能需要它.认为您的Windows服务仅具有对.Core项目的引用,并且想要使用本地化文本,比如说以其自己的语言向用户发送电子邮件.请注意,Windows服务通常不应引用Web层.因此,我们这里有一个务实的方法.我们可以将本地化添加到另一个dll项目中,但这会使解决方案更加复杂.

While normally it can be easily moved to web layer (no direct dependency in Core project), we put it in the Core layer since we think it may be needed in another application too. Think that you have a Windows Service has only Reference to the .Core project and want to use localization texts, say to send email to a user in his own language. Notice that Windows Service should not have a reference to Web layer normally. So, we have a pragmatic approach here. We could add localization to another dll project, but that would make the solution more complicated.

主要包括User,Role ..实体以及UserManager和RoleManager域类.与本地化类似,它不包含实际的授权逻辑.它还包括其他一些类,但它们的价值不高.我们认为,如果我们有更多的应用程序层,将它们放在此处将对我们有帮助.如您所知,作为最佳实践,每个应用程序都可以拥有自己的应用程序层.

Mainly includes User, Role.. entities and UserManager and RoleManager domain classes. Similar to localization, it does not include actual authorization logic. It also includes some other classes but they do not make much. We thought putting these here would help us if we have more application layers. As you know every application can have it's own application layer as a best practice.

AppConfigurations在此处共享不同应用程序(迁移器和Web应用程序)之间的配置读取"代码.同样,它可以在另一个"Shared Utils"库中.但是我们希望保持解决方案结构的平衡,因此它反映了主要的层和结构,但对于中级开发人员而言并没有那么复杂.

AppConfigurations is here to share 'configuration reading' code between different apps (Migrator and Web app). Again, this could be inside another "Shared Utils" library. But we wanted to keep solution structure balanced, so it reflects major layer and structures yet is not so complicated for intermediate level developers.

仅包含EditionManager类,它是用于版本管理的域服务.

Just includes EditionManager class which is a domain service for Edition management.

仅包含FeatureValueStore,它是一个类似于存储库的适配器类.看到它的代码,它已经是空的.

Just includes FeatureValueStore which is a repository-like adapter class. See it's code, it's already empty.

包括Tenant实体和TenantManager类,它们已经是域层的一部分.同样,这里没有任何东西包含与基础架构相关的多租户功能(例如数据过滤或确定当前租户).

Includes Tenant entity and TenantManager class which are already parts of domain layer. Again, nothing here includes infrastructure-related multi-tenancy features (like data filtering or determining current tenant).

...等等...

因此,不要只看名字和有想法,请更深入地检查项目.可以将一些代码移到高层或utils库中,但是我认为一般的结构对于启动DDD架构的应用程序是很好的.

So, do not just see names and have idea, please check the project deeper. Some code can be moved to upper layers or an utils library, but I think general structure is good to start a DDD architected application.

这篇关于ASP.NET Boilerplate域层似乎包含非域类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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