是什么IEditableObject和IRevertibleChangeTracking之间的区别? [英] What is the difference between IEditableObject and IRevertibleChangeTracking?

查看:293
本文介绍了是什么IEditableObject和IRevertibleChangeTracking之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之间有什么 IEditableObject 和<一的区别HREF =htt​​p://msdn.microsoft.com/en-us/library/afc366x8%28v=VS.100%29.aspx> IRevertibleChangeTracking (无论是从System.ComponentModel命名空间)?这看起来好像是第一个支持明确的事务,而第二个是比较含蓄 - 但最终结果是一样的。我应该如何去在代码中实现这一点?此刻我什么都不做的 BeginEdit 并调用 RejectChanges 的AcceptChanges 中的EndEdit 并的CancelEdit分别的。我的问题是,这也将接受前BeginEdit所做的更改。

What is the difference between IEditableObject and IRevertibleChangeTracking (both from the System.ComponentModel namespace)? It looks as if the first supports explicit transaction whilst the second is more implicit - but the net result is the same. How should I go about implementing this in code? At the moment I do nothing in BeginEdit and call RejectChanges and AcceptChanges in EndEdit and CancelEdit respectively. My problem is that this will also accept the changes made prior to the BeginEdit.

是真的是微软希望还是我想实现两个相互排斥的接口?

Is that really what Microsoft wanted or am I trying to implement two mutually exclusive interfaces?

推荐答案

这两个接口是不是相互排斥的。他们的只是为了支持不同但有些相关的场景,这还不如由同一给定类实现。这里有一个快速的解释:

The two interfaces are not mutually exclusive. They are simply intended to support different yet somewhat related scenarios, which might as well be implemented by the same given class. Here's a quick explanation:

IEditableObject 接口被设计为支持一个对象需要以某种特定方式的管理其内部状态场景而它正在编辑

The IEditableObject interface is designed to support the scenario where an object needs to manage its internal state in some particular way while it is being edited.

有关这个原因,界面包括显式标记,当编辑阶段开始时,完成或中止的方法,使相应的可以采取行动,在这些阶段修改对象的状态。

For that reason the interface includes methods that explicitly mark when the editing phase is started, completed or aborted, so that the appropriate actions can be taken to modify the object's state at those stages.

借助 IRevertibleChangeTracking 界面设计支持一个对象需要能够对场景中的回滚到以前的状态

The IRevertibleChangeTracking interface is designed to support the scenario where an object needs to be able to rollback to its previous state.

该接口具有标记方法时,该对象的当前状态应永久或应当恢复到上一个​​已知的永久状态。

The interface has methods that mark when the object's current state should be made permanent or it should be reverted to the last known permanent state.

这篇关于是什么IEditableObject和IRevertibleChangeTracking之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆