public ModelDelta Revert(IDataModel model) { var reverse = new ModelDelta { HasDataChange = HasDataChange }; foreach (var kvp in oldData) { var(index, data) = (kvp.Key, kvp.Value); reverse.oldData[index] = model[index]; model[index] = data; } foreach (var kvp in addedRuns) { reverse.removedRuns[kvp.Key] = kvp.Value; } foreach (var kvp in removedRuns) { reverse.addedRuns[kvp.Key] = kvp.Value; } foreach (var kvp in addedNames) { reverse.removedNames[kvp.Key] = kvp.Value; } foreach (var kvp in removedNames) { reverse.addedNames[kvp.Key] = kvp.Value; } foreach (var kvp in addedUnmappedPointers) { reverse.removedUnmappedPointers[kvp.Key] = kvp.Value; } foreach (var kvp in removedUnmappedPointers) { reverse.addedUnmappedPointers[kvp.Key] = kvp.Value; } foreach (var kvp in addedMatchedWords) { reverse.removedMatchedWords[kvp.Key] = kvp.Value; } foreach (var kvp in removedMatchedWords) { reverse.addedMatchedWords[kvp.Key] = kvp.Value; } model.MassUpdateFromDelta(addedRuns, removedRuns, addedNames, removedNames, addedUnmappedPointers, removedUnmappedPointers, addedMatchedWords, removedMatchedWords); return(reverse); }
public ModelArrayElement(IDataModel model, int address, int index, ModelDelta token) { (this.model, arrayAddress, arrayIndex) = (model, address, index); table = (ITableRun)model.GetNextRun(arrayAddress); this.token = token; }
public ModelTable(IDataModel model, int address, ModelDelta token = null) { (this.model, arrayAddress) = (model, address); this.token = token ?? new(); }
public ModelDelta Revert(IDataModel model) { var reverse = new ModelDelta { HasDataChange = HasDataChange }; foreach (var kvp in oldData) { var(index, data) = (kvp.Key, kvp.Value); reverse.oldData[index] = model.Count > index ? model[index] : (byte)0xFF; if (model.Count > index) { model[index] = data; } } foreach (var kvp in addedRuns) { reverse.removedRuns[kvp.Key] = kvp.Value; } foreach (var kvp in removedRuns) { reverse.addedRuns[kvp.Key] = kvp.Value; } foreach (var kvp in addedNames) { reverse.removedNames[kvp.Key] = kvp.Value; } foreach (var kvp in removedNames) { reverse.addedNames[kvp.Key] = kvp.Value; } foreach (var kvp in addedLists) { reverse.removedLists[kvp.Key] = kvp.Value; } foreach (var kvp in removedLists) { reverse.addedLists[kvp.Key] = kvp.Value; } foreach (var kvp in addedMatchedWords) { reverse.removedMatchedWords[kvp.Key] = kvp.Value; } foreach (var kvp in removedMatchedWords) { reverse.addedMatchedWords[kvp.Key] = kvp.Value; } foreach (var kvp in addedOffsetPointers) { reverse.removedOffsetPointers[kvp.Key] = kvp.Value; } foreach (var kvp in removedOffsetPointers) { reverse.addedOffsetPointers[kvp.Key] = kvp.Value; } foreach (var kvp in addedUnmappedPointers) { reverse.removedUnmappedPointers[kvp.Key] = kvp.Value; } foreach (var kvp in removedUnmappedPointers) { reverse.addedUnmappedPointers[kvp.Key] = kvp.Value; } foreach (var kvp in addedUnmappedConstants) { reverse.removedUnmappedConstants[kvp.Key] = kvp.Value; } foreach (var kvp in removedUnmappedConstants) { reverse.addedUnmappedConstants[kvp.Key] = kvp.Value; } if (oldDataLength != -1 || newDataLength != -1) { model.ExpandData(reverse, oldDataLength - 1); model.ContractData(reverse, oldDataLength - 1); } model.MassUpdateFromDelta(addedRuns, removedRuns, addedNames, removedNames, addedUnmappedPointers, removedUnmappedPointers, addedMatchedWords, removedMatchedWords, addedOffsetPointers, removedOffsetPointers, addedUnmappedConstants, removedUnmappedConstants, addedLists, removedLists); return(reverse); }