Exemple #1
0
        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);
        }
Exemple #2
0
 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);
 }
Exemple #3
0
        private IDisposable CaptureNonDataChange()
        {
            var initialState = HasAnyChange;

            if (HasAnyChange)
            {
                return(new StubDisposable());
            }
            return(new StubDisposable {
                Dispose = () => {
                    if (!HasAnyChange)
                    {
                        return;
                    }
                    OnNewChange?.Invoke(this, EventArgs.Empty);
                }
            });
        }
Exemple #4
0
 public new void Add(int num)
 {
     base.Add(num);
     OnNewChange?.Invoke(this, EventArgs.Empty);
 }