使用哪一种:统一拦截还是策略注入
我对使用哪个有疑问, 1. Unity Interception的用法[用于在运行时为对象添加新行为] 2. 或者使用策略注入应用程序块,我们可以在其中将处理程序连接到对象上的特定方法。
我现在正在使用 unity,并想决定哪一个是最好的或最有效的。我想跟踪[特定对象]正在消耗哪些资源。为此,我应该使用 1 或 2 中的哪一个。
我是否可以使用处理程序来动态识别调用者并使用它来说明使用或使用策略并单独维护它们。
I have a doubt regarding which to use,
1. the usage of the Interception with Unity [ used to add new behaviors for an object at runtime]
2. or to use the policy injection application block in which we can wireup handlers to specific methods on an object.
I am now using unity and want to decide which one is best or efficient. I want to track which resources are being consumed [for specific objects]. For this purpose, which one shall i use 1 or 2.
Whether I can use handlers to dynamically identify the caller and use that to account for a usage or use policy and maintain them separately.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
策略注入构建在 Unity 拦截之上(假设您使用的是当前版本的 Unity/Entlib)。策略注入实际上是作为一种拦截行为来实现的。
拦截行为可能稍微更有效,因为它们不需要执行大量复杂的匹配规则来根据方法调用来确定要调用哪个拦截器,但是如果您想将一个拦截器定位到一个拦截器,则它们需要您做更多的工作。具体方法。策略注入在设置时做了更多工作,但在调用时却很麻烦。
效率不会成为您的决定因素,您的整体设计和易用性才是决定因素。选择您更喜欢的一个。
Policy Injection is built on top of Unity interception (assuming you're using the current versions of Unity / Entlib). Policy Injection is actually implemented as an interception behavior.
Interception behaviors are probably slightly more efficient in that they don't need to do a lot of complex matching rules to figure out which interceptor to call based on a method call, but they require more work from you if you want to target one to a specific method. Policy injection does more work at setup time, but at call time it's a wash.
Efficiency isn't going to be your deciding factor, your overall design and ease of use will. Pick the one you like better.