Example #1
0
        /// <summary>
        ///     Remove a key from the list
        /// </summary>
        /// <param name="key">The key</param>
        public void RemoveKey(object key)
        {
            lock (((ICollection)this._keyList).SyncRoot)
            {
                var checkKey = new TableKey <T, TKey>((TKey)key, this._resolver);

                if (!this._keyList.Contains(checkKey))
                {
                    return;
                }
                this._keyList.Remove(checkKey);
                this._keyMap.Remove((TKey)key);
                this.IsDirty = true;
            }
        }
Example #2
0
        /// <summary>
        ///     Add a key to the list
        /// </summary>
        /// <param name="key">The key</param>
        public int AddKey(object key)
        {
            lock (((ICollection)this._keyList).SyncRoot)
            {
                var newKey = new TableKey <T, TKey>((TKey)key, this._resolver);

                if (!this._keyList.Contains(newKey))
                {
                    this._keyList.Add(newKey);
                    this._keyMap.Add((TKey)key, this.NextKey++);
                    this.IsDirty = true;
                }
                else
                {
                    var idx = this._keyList.IndexOf(newKey);
                    this._keyList[idx].Refresh();
                }
            }

            return(this._keyMap[(TKey)key]);
        }