private TValue MaybeNotify <TValue>( UInt32 tag, TValue newValue, TValue oldValue, EventHandler <FieldUpdateEventArgs <TValue, OldHit> > handler, bool shouldNotify ) { if (shouldNotify) { var args = new FieldUpdateEventArgs <TValue, OldHit>(tag, newValue, oldValue, this); handler?.Invoke(this, args); } return(newValue); }
public void ReplaceAt(UInt32 tag, WireType wireType, IReader reader, bool shouldNotify) { if (tag >= this.Count) { throw new IndexOutOfRangeException(); } var newItem = StateFactory.Deserialize <T>(reader, this.Path, tag); var oldItem = this[(int)tag]; if (shouldNotify) { var args = new FieldUpdateEventArgs <T, StateList <T> >(tag, newItem, oldItem, this); this.OnUpdate?.Invoke(this, args); } this.Items[(int)tag] = newItem; }
public void ReplaceAt(UInt32 tag, WireType wireType, IReader reader, bool shouldNotify) { var newValue = StateFactory.Deserialize <T>(reader, this.Path, tag); if (shouldNotify) { if (this.ContainsKey(tag)) { var oldValue = this[tag]; var args = new FieldUpdateEventArgs <T, StateMap <T> >(tag, newValue, oldValue, this); this.OnUpdate?.Invoke(this, args); } else { var args = new MapInsertEventArgs <T, StateMap <T> >(tag, newValue, this); this.OnInsert?.Invoke(this, args); } } this.Dictionary[tag] = newValue; }