Share via


ILinkedUndoTransaction Interface

A transaction allows you to group together operations on the UML model store, so that if any of them fails, the whole group is rolled back. After the transaction is committed, the user can undo the whole group with a single undo command.

Namespace:  Microsoft.VisualStudio.Modeling.ExtensionEnablement
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.11.0 (in Microsoft.VisualStudio.Modeling.Sdk.11.0.dll)

Syntax

'Declaration
Public Interface ILinkedUndoTransaction _
    Inherits IDisposable
public interface ILinkedUndoTransaction : IDisposable
public interface class ILinkedUndoTransaction : IDisposable
type ILinkedUndoTransaction =  
    interface 
        interface IDisposable 
    end
public interface ILinkedUndoTransaction extends IDisposable

The ILinkedUndoTransaction type exposes the following members.

Properties

  Name Description
Public property Id The name of this transaction set by BeginTransaction.

Top

Methods

  Name Description
Public method Abort Undo all the changes to the model store that have occurred since the transaction was created. Disposing the transaction without committing it has the same effect. Abort will not undo changes to other program variables, or external resources.
Public method Commit Complete the transaction so that when it is disposed, the operations performed within it will not be undone.
Public method Dispose Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.)

Top

Remarks

In a Visual Studio extension, you can to obtain a context from which an ILinkedUndoTransaction can be created as follows:

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

In a method, you can create a transaction from this context:

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

An exception that is not caught inside the using block will cause all the UML model changes inside it to be rolled back. Note that this applies only to changes on the UML model, and not to changes that have been made to other variables, external databases, files, and so on.

Transactions can be nested.

For more information, see How to: Link Model Updates using Transactions.

See Also

Reference

Microsoft.VisualStudio.Modeling.ExtensionEnablement Namespace