Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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.10.0 (in Microsoft.VisualStudio.Modeling.Sdk.10.0.dll)

public interface ILinkedUndoTransaction : IDisposable

The ILinkedUndoTransaction type exposes the following members.

  NameDescription
Public propertyIdThe name of this transaction set by BeginTransaction().
Top

  NameDescription
Public methodAbortUndo 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 methodCommitComplete the transaction so that when it is disposed, the operations performed within it will not be undone.
Public methodDisposePerforms application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.)
Top

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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft