public virtual bool ChangeData(IDataModel model, int index, byte data) { if (model.Count > index && model[index] == data) { return(false); } if (!oldData.ContainsKey(index)) { if (model.Count <= index) { model.ExpandData(this, index); } oldData[index] = model[index]; } var valueChanged = model[index] != data; model[index] = data; if (!HasDataChange) { HasDataChange = true; OnNewChange?.Invoke(this, EventArgs.Empty); } return(valueChanged); }
public bool SetDataLength(IDataModel model, int length) { oldDataLength = model.RawData.Length; newDataLength = length; if (!HasAnyChange) { HasDataChange |= oldDataLength != newDataLength; if (HasDataChange) { OnNewChange?.Invoke(this, EventArgs.Empty); } } return(true); }
private IDisposable CaptureNonDataChange() { var initialState = HasAnyChange; if (HasAnyChange) { return(new StubDisposable()); } return(new StubDisposable { Dispose = () => { if (!HasAnyChange) { return; } OnNewChange?.Invoke(this, EventArgs.Empty); } }); }
public new void Add(int num) { base.Add(num); OnNewChange?.Invoke(this, EventArgs.Empty); }