private void clearDataTracker() { var previousTracker = newData.Readonly.ReadonlyChangeTracker.PreviousTracker; if (previousTracker != null) { List <MemoryIndex> indexes = new List <MemoryIndex>(); CollectionMemoryUtils.AddAll(indexes, newStructure.Readonly.ReadonlyChangeTracker.IndexChanges); IReadOnlySnapshotData previousData = previousTracker.Container; foreach (MemoryIndex index in indexes) { if (index is TemporaryIndex) { newStructure.Writeable.WriteableChangeTracker.RemoveIndexChange(index); } else { MemoryEntry newEntry = getMemoryEntryOrEmpty(index, newData.Readonly); MemoryEntry previousEntry = getMemoryEntryOrEmpty(index, previousData); if (ValueUtils.CompareMemoryEntries(newEntry, previousEntry)) { newData.Writeable.WriteableChangeTracker.RemoveIndexChange(index); } } } } }
private MemoryEntry getMemoryEntryOrEmpty(MemoryIndex index, IReadOnlySnapshotData snapshotdata) { MemoryEntry entry = null; if (!snapshotdata.TryGetMemoryEntry(index, out entry)) { entry = null; } return(entry); }
/// <inheritdoc /> public ISnapshotDataProxy CreateNewInstanceWithData(IReadOnlySnapshotData oldData) { TrackingSnapshotDataAssociativeContainer data = oldData as TrackingSnapshotDataAssociativeContainer; if (data != null) { return(new TrackingSnapshotDataProxy(data)); } else { throw new InvalidCastException("Argument is not of type TrackingSnapshotDataAssociativeContainer"); } }
/// <summary> /// Gets the memory entry for given index in given data conatiner. /// </summary> /// <param name="snapshot">The snapshot.</param> /// <param name="data">The data.</param> /// <param name="index">The index.</param> /// <returns>Associated index if exists; otherwise an empty entry insatnce, created by the snapshot</returns> public static MemoryEntry GetMemoryEntry(Snapshot snapshot, IReadOnlySnapshotData data, MemoryIndex index) { MemoryEntry memoryEntry; if (data.TryGetMemoryEntry(index, out memoryEntry)) { return(memoryEntry); } else { return(snapshot.EmptyEntry); } }
/// <summary> /// Gets the source entry. /// </summary> /// <param name="targetIndex">Index of the target.</param> /// <param name="sourceSnapshot">The source snapshot.</param> /// <returns>Source memory entry</returns> private MemoryEntry getSourceEntry(MemoryIndex targetIndex, Snapshot sourceSnapshot) { IReadOnlySnapshotData data = sourceSnapshot.CurrentData.Readonly; MemoryEntry sourceEntry = null; if (!data.TryGetMemoryEntry(targetIndex, out sourceEntry)) { MemoryIndex sourceIndex; if (targetSnapshot.MergeInfo.GetOrCreateDatasourcesContaier(targetIndex).TryGetDatasource(sourceSnapshot, out sourceIndex)) { data.TryGetMemoryEntry(sourceIndex, out sourceEntry); } } return(sourceEntry); }
/// <inheritdoc /> public virtual void ReinitializeTracker(IReadOnlySnapshotData parentSnapshotData) { }
/// <inheritdoc /> public override void ReinitializeTracker(IReadOnlySnapshotData parentSnapshotData) { tracker = new ChangeTracker <IReadOnlySnapshotData>(this.DataId, this, parentSnapshotData.ReadonlyChangeTracker); }