ILinkedUndoTransaction 接口

事务一起允许您在 UML 模型存储区的组操作,,因此,如果任何一个失败,整个组回滚。在事务提交后,用户可以取消具有唯一的整组撤消命令。

命名空间:  Microsoft.VisualStudio.Modeling.ExtensionEnablement
程序集:  Microsoft.VisualStudio.Modeling.Sdk.11.0(在 Microsoft.VisualStudio.Modeling.Sdk.11.0.dll 中)

语法

声明
Public Interface ILinkedUndoTransaction _
    Inherits IDisposable
public interface ILinkedUndoTransaction : IDisposable

ILinkedUndoTransaction 类型公开以下成员。

属性

  名称 说明
公共属性 Id BeginTransaction 此设置事务的名称。

页首

方法

  名称 说明
公共方法 Abort 发生取消了模型存储的所有更改,则事务时创建的。配置不对它的事务具有相同的效果。中止不会撤消对其他程序变量的更改或外部资源。
公共方法 Commit 完成事务,以便,以便在配置时,在其中执行的操作不会被取消。
公共方法 Dispose 执行与释放或重置非托管资源相关的应用程序定义的任务。 (继承自 IDisposable。)

页首

备注

在 Visual Studio 扩展,则可以获取ILinkedUndoTransaction 可以创建的上下文如下所示:

[Import]
public ILinkedUndoContext LinkedUndoContext { get; set; }

在方法中,可以创建从此上下文的事务:

using (ILinkedUndoTransaction transaction =
              LinkedUndoContext.BeginTransaction("Swap names"))
{ 
    Operation1();
    Operation2();
    transaction.Commit(); // Always remember Commit()!
}

未捕获 using 内的异常块将导致在其中的任何 UML 模型更改回滚。请注意这仅适用于 UML 模型中的更改,而不是对其他变量的更改,外部数据库,文件,依此类推。

事务可以嵌套。

有关更多信息,请参见 如何:使用事务链接模型更新

请参见

参考

Microsoft.VisualStudio.Modeling.ExtensionEnablement 命名空间