为什么 PropertyInfoManager 不像 FieldManager 那样包含在 BusinessBase 中?
我知道 FieldManager 在 BusinessBase 中作为受保护的属性公开。为什么 PropertyInfoManager 设置方式不同?据我所知,PropertyInfoManger 维护着一个类型字典和每个类型的 PropertyInfo 列表。在 BusinessBase 中维护一个 PropertyInfo 列表似乎更容易,类似于 FieldManager 的工作方式。 PropertyInfoManager 中做了很多工作来将正在注册的 PropertyInfo 与其所属的类型链接起来。
我确信这是有原因的,只是我没有看到或理解得不够。我只是想更多地了解 CSLA 以及为什么事情是这样构建的。
I know that FieldManager is exposed as a protected property within BusinessBase. Why isn't PropertyInfoManager setup the same way? From what I can gather, PropertyInfoManger maintains a dictionary of Types and a list of each Type’s PropertyInfo(s). It would seem easier to just have a list of PropertyInfo(s) maintained within BusinessBase, similar to how the FieldManager works. There is a lot of work done in PropertyInfoManager to link up the PropertyInfo being registered with the Type they belong to.
I am sure there is a reason for this and I just don’t see it or understand it enough. I am just trying to learn more about CSLA and why things were built the way they were.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这样做有两个主要原因:
1) 线程安全 - PropertyInfoManager 类基本上是字典的静态包装器,它允许您注册类型的 PropertyInfo 并获取类型的 PropertyInfo 。它处理锁定以确保线程安全。
2) N 级撤消 - CSLA 的此功能增加了存储字段值的复杂性,受保护的 FieldManager 负责维护 BusinessBase 的所有托管支持字段的值。为此,FieldDataManager 类需要访问该类型的 PropertyInfo,因此将它们放在一个位置而不是从 BusinessBase 传递一些列表是一种更好的方法。
在本例中,FieldDataManager 和 PropertyInfoManager 类添加了模块化性,我确信在设计时受到了关注点分离 (SoC) 和单一职责原则 (SRP) 的影响。
我也在学习 CLSA,并在此过程中从框架本身学到了很多关于面向对象设计的知识。我会推荐这本书并阅读源代码以继续了解有关 CSLA .Net 的更多信息。
There are two major reasons I can see to do this:
1) Thread safety - the PropertyInfoManager class is basically a static wrapper around a Dictionary which allows you to register PropertyInfo(s) for a Type and Get the PropertyInfo(s) for a Type. It handles the locking to ensure thread safety.
2) N-Level Undo - this feature of CSLA adds a lot of complexity to storing field values, the protected FieldManager is responsible for maintaining values of all managed backing fields for a BusinessBase. To do this the FieldDataManager class needs access to the PropertyInfo(s) of the type so having these in one place instead of passing some List around from the BusinessBase is a better approach.
In this case the FieldDataManager and PropertyInfoManager classes add modularity and I'm sure were influenced by Separation of Concerns (SoC) and the Single Responsibility Principle (SRP) when designed.
I am also learning about CLSA and in doing so have learned quite a bit about Object Oriented Design from the framework itself. I would recommend The Book and reading The Source Code to continue to learn more about CSLA .Net.