在领域驱动设计中,工厂类可以访问基础设施吗?
如果有必要,工厂可以访问基础设施的元素来构建对象?在特定情况下,我有一个对象需要添加电子邮件签名,该签名作为参数存储在应用程序的配置层中。
If necessary, a factory can access elements of the infrastructure to build an object?. In a particular case, I have an object that I need to add email signature that is stored as a parameter in the configuration layer of the application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

在 DDD 中,工厂与存储库处于相同的架构级别,但用于创建新对象而不是加载现有对象。因此它可以像存储库一样调用基础设施服务。
In DDD, a Factory is at the same architectural level as a Repository, but for creating new objects instead of loading existing objects. So it can call infrastructure services just like the repository.