/// <summary> /// Adds a new change definition to this IChangeTrackingService. /// </summary> /// <param name="change">The change to store.</param> /// <param name="behavior">The requested behavior.</param> public virtual void Add( IChange change, AddChangeBehavior behavior ) { this.EnsureNotSuspended(); Ensure.That( change ) .Named( "change" ) .IsNotNull(); if ( this.IsInAtomicOperation ) { this.AtomicOperation.Add( change, behavior ); } else { /* * è necessario agganciare gli eventi * Committed e Rejected su IChange perchè * se viene manualmente chiamato Commit o Reject * su una IChange dobbiamo liberarcene anche noi */ lock ( SyncRoot ) { switch ( behavior ) { case AddChangeBehavior.Default: this.forwardChangesStack.Clear(); this.backwardChangesStack.Add( change ); break; case AddChangeBehavior.RedoRequest: this.backwardChangesStack.Add( change ); break; case AddChangeBehavior.UndoRequest: this.forwardChangesStack.Add( change ); break; case AddChangeBehavior.None: throw new ArgumentOutOfRangeException(); default: throw new EnumValueOutOfRangeException(); } this.OnWire( change ); } this.OnTrackingServiceStateChanged(); } }
/// <summary> /// Adds the specified change. /// </summary> /// <param name="change">The change.</param> /// <param name="behavior">The behavior.</param> public void Add(IChange change, AddChangeBehavior behavior) { this.changes.Add(new Tuple <IChange, AddChangeBehavior>(change, behavior)); }
IAtomicOperation BeginAtomicOperation( AddChangeBehavior behavior ) { Ensure.That( this.IsInAtomicOperation ) .WithMessage( "Only one single atomic operation can be created at a time." ) .Is( false ); Action<AtomicChange> completed = c => { this.AtomicOperation = null; this.Add( c, behavior ); /* * Qui potrebbe aver senso recuperare dalla IChange * tutte le transient entities e travasarle nelle transient entities * locali. */ c.MergeTransientEntities( this.transientEntities ); }; Action disposed = () => { this.AtomicOperation = null; }; this.AtomicOperation = new AtomicOperation( completed, disposed ); return this.AtomicOperation; }
public void Add(IChange change, AddChangeBehavior behavior) { this.change.Add(change, behavior); }
internal IChange InvokeCacheChange <T>(T value, RejectCallback <T> rc, CommitCallback <T> cc, AddChangeBehavior behavior) { return(base.CacheChange("property-name", value, rc, cc, behavior)); }
public void Add( IChange change, AddChangeBehavior behavior ) { this.change.Add( change, behavior ); }
/// <summary> /// Caches the supplied item in the active change tracking service. /// </summary> /// <typeparam name="T">The system type of the item to cache.</typeparam> /// <param name="propertyName">Name of the property.</param> /// <param name="value">The value to cache.</param> /// <param name="restore">A delegate to call when the change tracking /// service needs to restore the cached change.</param> /// <param name="commit">A delegate to call when the change tracking /// service needs to commit the cached change. Passing a null item for /// this parameter means that this instance does not need to be notified when /// the change is committed.</param> /// <param name="direction">The direction.</param> /// <returns> /// A reference to the cached change as an instance of <see cref="IChange"/> interface. /// </returns> protected IChange CacheChange <T>(string propertyName, T value, RejectCallback <T> restore, CommitCallback <T> commit, AddChangeBehavior direction) { this.EnsureNotDisposed(); if (this.IsTracking) { IChange iChange = new PropertyValueChange <T>(this, propertyName, value, restore, commit, string.Empty); ((IMemento)this).Memento.Add(iChange, direction); return(iChange); } return(null); }