层之间的名称冲突
所以我正在开发一个非常酷(而且非常大)的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,我遇到过这个问题,但我每次都很快修复了它。
良好的类命名约定会有所帮助。避免在多个层的类中使用相同的名称。
或者,您可以使用命名空间别名,这样您就可以使用,例如:
这有帮助吗?
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:
Does this help?