/// <summary> /// Replays the changes in the current <see cref="Book"/> that have taken place since the <paramref name="savePoint"/> has been created. /// </summary> /// <param name="dataAdapter">The <see cref="ISaver"/> to which to replay the changes.</param> /// <param name="savePoint">The <see cref="SavePoint"/> from which the changes should be replayed. If null, the entirety of the current <see cref="Book"/> will be replayed.</param> public void Replay(ISaver dataAdapter, SavePoint savePoint = null) { SaveTrack track; lock (this.lockMutex) { if (savePoint != null) { if (!this.saveTracks.ContainsKey(savePoint)) { throw new InvalidOperationException("Could replay the book's modifications, because the save point could not be found."); } track = this.saveTracks[savePoint]; } else { track = this.baseSaveTrack; } } lock (track) { track.Replay(dataAdapter); } }
internal void RemoveSavePoint(SavePoint savePoint) { lock (this.lockMutex) { if (!this.saveTracks.ContainsKey(savePoint)) { throw new InvalidOperationException("Could not remove the save point, because it does not exist in the book."); } this.saveTracks.Remove(savePoint); } }
/// <summary> /// Creates a <see cref="SavePoint"/> that can be used to keep track of changes in the current <see cref="Book"/>. /// </summary> /// <returns>A <see cref="SavePoint"/> corresponding to the current state of the current <see cref="Book"/>.</returns> public SavePoint CreateSavePoint() { lock (this.lockMutex) { var savePoint = new SavePoint(this); this.saveTracks.Add(savePoint, new SaveTrack()); return savePoint; } }