adTempus API
ArcanaDevelopment.adTempus.Client Namespace / ObjectBase Class / BeginEdit Method / BeginEdit(UndoLevelAction) Method
The action to take when the UndoLevel object is disposed, if a Commit or Undo is not performed explicitly.
Example


In This Topic
    BeginEdit(UndoLevelAction) Method
    In This Topic
    Creates an undo snapshot and returns an UndoLevel object that is used to automatically commit or revert changes when it goes out of scope.
    Syntax
    'Declaration
     
    
    Public Overloads Function BeginEdit( _
       ByVal defaultAction As UndoLevelAction _
    ) As UndoLevel

    Parameters

    defaultAction
    The action to take when the UndoLevel object is disposed, if a Commit or Undo is not performed explicitly.
    Remarks

    BeginEdit returns an UndoLevel object, which implements IDisposable. When the UndoLevel object is disposed, it applies the defaultAction to the object if the snapshot created by BeginEdit has not already been explicitly committed or discarded.

    This example demonstrates proper use of the UndoLevel. void EditAnObject(ObjectBase anObject) { using(anObject.BeginEdit(UndoLevelAction.Revert)) { //...perform operations on the object. anObject.CommitEdit(); //explicitly commit the changes. } //when UndoLevel goes out of scope, nothing happens, because changes have already been committed. using(anObject.BeginEdit(UndoLevelAction.Revert)) { //...perform operations on the object. //...No explicit Commit or Undo call. } //when UndoLevel goes out of scope, the UndoLevel calls UndoEdit to revert the changes. }
    Example
    This example demonstrates proper use of the UndoLevel.
    void EditAnObject(ObjectBase anObject)
    {
        using(anObject.BeginEdit(UndoLevelAction.Revert))
        {
            //...perform operations on the object.
            anObject.CommitEdit();  //explicitly commit the changes.
        }   //when UndoLevel goes out of scope, nothing happens, because changes have already been committed.
                
        using(anObject.BeginEdit(UndoLevelAction.Revert))
        {
            //...perform operations on the object.
            //...No explicit Commit or Undo call.
        }   //when UndoLevel goes out of scope, the UndoLevel calls UndoEdit to revert the changes.
    }
    See Also