层之间的名称冲突

发布于 2024-08-14 03:13:19 字数 709 浏览 3 评论 0原文

所以我正在开发一个非常酷(而且非常大)的 n 层应用程序。

基本上我有以下程序集:


域.合同

服务
服务.

合同演示.管理
演示文稿.Web
Presentation.Core(在管理和Web之间共享)
我可以实现Presentation.Core.Contracts

我正在努力解决的主要问题是不同层之间的名称冲突。即。

Services.Contracts.AccountServicesRequest
Domain.Contracts.AccountServicesRequest

我对服务名称也有同样的问题(在这种情况下,我只是使用类作为服务而不是 WCF 等)。即:

Services.Contracts.IAccountService
Domain.Contracts.IAccountService

我现在通过在域层 IxxxServiceHandler 中创建所有“服务处理程序”解决了这个问题,这给了我这个:

Services.Contracts.IAccountService
Domain.Contracts.IAccountServiceHandler

但是,我无法通过在层之间来回传递的对象来解决此问题。 这似乎通过我的解决方案散布在很多地方。 我只是很好奇是否有人遇到过同样的问题。如果是这样,你是如何解决的?

So I'm developing a very cool (and very large) n-tier application.

Basically I have the following assemblies:

Domain
Domain.Contracts

Services
Services.Contracts

Presentation.Admin
Presentation.Web
Presentation.Core (shared between Admin & Web)
I may implement Presentation.Core.Contracts

My main issue I'm wrestling with are name collisions between the different layers. Ie.

Services.Contracts.AccountServicesRequest
Domain.Contracts.AccountServicesRequest

I had the same issue with Service names (in this case I am just using classes as services rather than WCF, etc). Ie:

Services.Contracts.IAccountService
Domain.Contracts.IAccountService

I resolved this by now making all "service handlers" in the domain layer IxxxServiceHandler which gives me this:

Services.Contracts.IAccountService
Domain.Contracts.IAccountServiceHandler

However, I haven't been able to resolve this issue with the objects that are passed back and forth between layers.
This seems to be sprinkled in a bunch of places through my solution(s).
I was just curious to see if anyone has had the same issues. If so, how did you resolve them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆流 2024-08-21 03:13:19

是的,我遇到过这个问题,但我每次都很快修复了它。

良好的类命名约定会有所帮助。避免在多个层的类中使用相同的名称。

或者,您可以使用命名空间别名,这样您就可以使用,例如:

services::IAccountService
domain::IAccountService

这有帮助吗?

Yes, I have run into this problem, but I have fixed it soon enough every time.

A good class naming convention can help. Avoid using the same name in classes across multiple layers.

Alternatively, you can use namespace aliases, so that you would be using, for example:

services::IAccountService
domain::IAccountService

Does this help?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文