Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        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;
        }