/// <summary> /// Ensures that any changes to the Dataset (if any) are discarded /// </summary> /// <remarks> /// Rollsback the Active Transaction /// </remarks> public sealed override void Discard() { int i = this._actions.Count - 1; int total = this._actions.Count; while (i >= 0) { GraphPersistenceAction action = this._actions[i]; switch (action.Action) { case GraphPersistenceActionType.Added: //If a Graph was added we must now remove it if (this.HasGraphInternal(action.Graph.BaseUri)) { this.RemoveGraphInternal(action.Graph.BaseUri); } break; case GraphPersistenceActionType.Deleted: //If a Graph was deleted we must now add it back again //Don't add the full Graph only an empty Graph with the given URI Graph g = new Graph(); g.BaseUri = action.Graph.BaseUri; this.AddGraphInternal(g); break; case GraphPersistenceActionType.Modified: //If a Graph was modified we must discard the changes action.Graph.Discard(); break; } i--; } if (total == this._actions.Count) { this._actions.Clear(); } else { this._actions.RemoveRange(0, total); } //Ensure any modifiable Graphs we've looked at have been Discarded foreach (ITransactionalGraph g in this._modifiableGraphs.Graphs.OfType <ITransactionalGraph>()) { g.Discard(); } this._modifiableGraphs = new TripleStore(); this.DiscardInternal(); }
/// <summary> /// Ensures that any changes to the Dataset (if any) are flushed to the underlying Storage /// </summary> /// <remarks> /// Commits the Active Transaction /// </remarks> public sealed override void Flush() { int i = 0; while (i < this._actions.Count) { GraphPersistenceAction action = this._actions[i]; switch (action.Action) { case GraphPersistenceActionType.Added: //If Graph was added ensure any changes were flushed action.Graph.Flush(); break; case GraphPersistenceActionType.Deleted: //If Graph was deleted can discard any changes action.Graph.Discard(); break; case GraphPersistenceActionType.Modified: //If Graph was modified ensure any changes were flushed action.Graph.Flush(); break; } i++; } this._actions.Clear(); //Ensure any Modifiable Graphs we've looked at have been Flushed() foreach (ITransactionalGraph g in this._modifiableGraphs.Graphs.OfType <ITransactionalGraph>()) { g.Flush(); } this._modifiableGraphs = new TripleStore(); this.FlushInternal(); }