Exemplo n.º 1
0
            private void Source_CollectionChanged(object aSender, NotifyCollectionChangedEventArgs aArgs)
            {
                switch (aArgs.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    //CheckOneOrNone(aArgs.NewItems);
                    OnItemAdded?.Invoke(Source, aArgs.NewStartingIndex, (T)aArgs.NewItems[0]);
                    break;

                case NotifyCollectionChangedAction.Move:
                    //CheckOneOrNone(aArgs.NewItems);
                    OnItemMoved?.Invoke(Source, aArgs.OldStartingIndex, aArgs.NewStartingIndex, (T)aArgs.NewItems[0]);
                    break;

                case NotifyCollectionChangedAction.Remove:
                    //CheckOneOrNone(aArgs.OldItems);
                    OnItemRemoved?.Invoke(Source, aArgs.OldStartingIndex, (T)aArgs.OldItems[0]);
                    break;

                case NotifyCollectionChangedAction.Replace:
                    //CheckOneOrNone(aArgs.NewItems);
                    OnItemReplaced?.Invoke(Source, aArgs.OldStartingIndex, (T)aArgs.OldItems[0], (T)aArgs.NewItems[0]);
                    break;

                case NotifyCollectionChangedAction.Reset:
                    OnCleared?.Invoke(Source);
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
Exemplo n.º 2
0
        internal int RemoveExpiredValues()
        {
            int numItemsRemoved = 0;

            try
            {
                var node = _doubleLinkedList.First;
                while (node != null)
                {
                    var nextNode = node.Next;
                    if (node.Value.ExpirationTime < DateTime.UtcNow)
                    {
                        _doubleLinkedList.Remove(node);
                        if (_map.TryRemove(node.Value.Key, out var cacheItem))
                        {
                            OnItemRemoved?.Invoke(cacheItem.Value);
                        }

                        numItemsRemoved++;
                    }

                    node = nextNode;
                }
            }
            catch (ObjectDisposedException ex)
            {
                LogHelper.LogWarning(LogHelper.FormatInvariant(LogMessages.IDX10902, nameof(RemoveExpiredValues), ex));
            }

            return(numItemsRemoved);
        }
Exemplo n.º 3
0
 private void OnItemRemovedEvent()
 {
     if (Item.IsAir)
     {
         OnItemRemoved?.Invoke(this);
     }
 }
Exemplo n.º 4
0
 public void RemoveItem(ItemInstance item)
 {
     if (_items.Remove(item))
     {
         UpdateItemsView();
         OnItemRemoved?.Invoke(item);
     }
 }
Exemplo n.º 5
0
 void OnTriggerExit(Collider other)
 {
     OnItemRemoved.Invoke(ItemInstance.data, groupId, null);
     ItemInstance.isInSlot = false;
     ItemInstance.transform.SetParent(null);
     highlightRenderer.enabled = false;
     ItemInstance = null;
 }
 public void RemoveAndNotify(int position)
 {
     if (OnItemRemoved != null && OnItemRemoved.GetInvocationList().Any())
     {
         OnItemRemoved(new PosArgs(position));
     }
     base.RemoveAt(position);
 }
Exemplo n.º 7
0
 public void RemoveItem(int index)
 {
     Items[index].UpdateTower(null);
     AllEffects.RemoveWhere(effect => effect.Item == Items[index]);
     Items.RemoveAt(index);
     UpdateStats();
     OnItemRemoved?.Invoke(this, index);
 }
Exemplo n.º 8
0
        protected override void RemoveItem(int index)
        {
            var removedItem = this[index];

            base.RemoveItem(index);

            OnItemRemoved?.Invoke(this, new ItemRemovedEventArgs <T>(removedItem));
        }
Exemplo n.º 9
0
        public void Remove(TKey key)
        {
            var value = _dictionary[key];

            _dictionary.Remove(key);

            OnItemRemoved?.Invoke(key, value);
        }
Exemplo n.º 10
0
 public void Remove(T item)
 {
     if (!content.Contains(item))
     {
         return;
     }
     content.Remove(item);
     OnItemRemoved?.Invoke(item);
 }
 public bool Remove(IContainable item)
 {
     if (Contents.Remove(item))
     {
         OnItemRemoved?.Invoke(this, EventArgs.Empty);
         return(true);
     }
     return(false);
 }
Exemplo n.º 12
0
        public bool Remove(string deviceKey)
        {
            var result = _cameraCollection.TryRemove(deviceKey, out Camera camera);

            if (result)
            {
                OnItemRemoved?.Invoke(this, camera);
            }
            return(result);
        }
Exemplo n.º 13
0
 public void RemoveItem(Item itemToRemove)
 {
     if (Items.Contains(itemToRemove) == false)
     {
         Debug.Log(itemToRemove.Name + " can't be found");
         return;
     }
     Items.Remove(itemToRemove);
     OnItemRemoved?.Invoke(itemToRemove);
 }
Exemplo n.º 14
0
        public bool Remove(string id)
        {
            bool isRemoved = false;

            if (Items.TryGetValue(id, out T item))
            {
                isRemoved = Items.Remove(id);
                OnItemRemoved?.Invoke(this, item);
            }

            return(isRemoved);
        }
Exemplo n.º 15
0
        public T Remove()
        {
            T item;

            lock (this)
            {
                item = this[GetIndexToRemove()];
                Remove(item);
            }
            OnItemRemoved?.Invoke(this, new ItemEventArgs <T>(item));
            return(item);
        }
Exemplo n.º 16
0
        public void Remove(Item item)
        {
            if (!_items.Contains(item))
            {
                Debug.LogError($"Inventory does not contain {item} ! Could not remove.");
                return;
            }

            _items.Remove(item);
            CurrentWeight -= item.itemSO.weight;
            OnItemRemoved?.Invoke(item);
            item.Drop();
        }
        protected void RemoveOldest()
        {
            lock (_lockObject)
            {
                if (itemList.Count > 0)
                {
                    var item = itemList[0];
                    itemList.RemoveAt(0);

                    OnItemRemoved?.Invoke(item, EventArgs.Empty);

                    Move(-1);
                }
            }
        }
Exemplo n.º 18
0
        internal void RemoveLRUs()
        {
            // use the _capacity for the newCacheSize calculation in the case where the cache is experiencing overflow
            int currentCount = _map.Count <= _capacity ? _capacity : _map.Count;
            var newCacheSize = currentCount - (int)(currentCount * _compactionPercentage);

            while (_map.Count > newCacheSize && _doubleLinkedList.Count > 0)
            {
                var lru = _doubleLinkedList.Last;
                if (_map.TryRemove(lru.Value.Key, out var cacheItem))
                {
                    OnItemRemoved?.Invoke(cacheItem.Value);
                }

                _doubleLinkedList.Remove(lru);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Remove the given enumeration of items from the reactive set.
        /// </summary>
        /// <param name="Items">An enumeration of items.</param>
        public ReactiveSet <T> Remove(IEnumerable <T> Items)
        {
            if (Items != null && Items.Any())
            {
                lock (_Set)
                {
                    var Timestamp = DateTime.Now;

                    Items.ForEach(Item => {
                        _Set.Remove(Item);

                        OnItemRemoved?.Invoke(Timestamp, this, Item);
                    });
                }
            }

            return(this);
        }
Exemplo n.º 20
0
        /// <summary>
        ///     Removes first item from the back of the buffer
        /// </summary>
        /// <returns></returns>
        public T PopBack()
        {
            if (IsEmpty)
            {
                throw new IndexOutOfRangeException("You cannot remove item from empty collection");
            }
            var result = Back();

            Count--;
            if (!IsEmpty)
            {
                IncreaseBackIndex();
            }
            else
            {
                _frontItem = 0;
                _backItem  = 0;
            }
            OnItemRemoved?.Invoke(this, new ItemRemovedEventArgs(false, result));
            return(result);
        }
        private void CheckForChanges()
        {
            var newState = Values.ToList();

            foreach (var competition in _state)
            {
                if (newState.All(newCompetition => newCompetition.Id != competition.Id))
                {
                    OnItemRemoved?.Invoke(competition);
                }
            }

            foreach (var competition in newState)
            {
                if (_state.All(newCompetition => newCompetition.Id != competition.Id))
                {
                    OnItemAdded?.Invoke(competition);
                }
            }

            _state = newState;
        }
Exemplo n.º 22
0
        /// Removes a particular key from the cache.
        public bool TryRemove(TKey key, out TValue value)
        {
            if (key == null)
            {
                throw LogHelper.LogArgumentNullException(nameof(key));
            }

            if (!_map.TryGetValue(key, out var cacheItem))
            {
                value = default;
                return(false);
            }

            value = cacheItem.Value;
            _eventQueue.Add(() => _doubleLinkedList.Remove(cacheItem));
            if (_map.TryRemove(key, out cacheItem))
            {
                OnItemRemoved?.Invoke(cacheItem.Value);
                return(true);
            }

            return(false);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Remove the given enumeration of items from the reactive set.
        /// </summary>
        /// <param name="Items">An enumeration of items.</param>
        public ReactiveSet <T> Set(IEnumerable <T> Items)
        {
            if (Items?.Any() == true)
            {
                lock (_Set)
                {
                    var ToAdd     = Items.Except(_Set).ToArray();
                    var ToRemove  = _Set.Except(Items).ToArray();
                    var Timestamp = DateTime.Now;

                    ToRemove.ForEach(Item => {
                        _Set.Remove(Item);
                        OnItemRemoved?.Invoke(Timestamp, this, Item);
                    });

                    ToAdd.ForEach(Item => {
                        _Set.Add(Item);
                        OnItemAdded?.Invoke(Timestamp, this, Item);
                    });
                }
            }

            return(this);
        }
Exemplo n.º 24
0
 /// <summary>
 /// Removes the given item from the inventory
 /// </summary>
 /// <param name="item">The item to be removed</param>
 private void RemoveItem(Item item)
 {
     OnItemRemoved?.Invoke(item, this);
     _inventoryItems.Remove(item);
 }
Exemplo n.º 25
0
 private void RaiseRemoved(ItemInstance instance)
 {
     OnItemRemoved?.Invoke(instance);
 }
Exemplo n.º 26
0
 public void RemoveItem(int index)
 {
     Debug.Log("Remove Item: " + _itemList[index].itemType);
     _itemList.RemoveAt(index);
     OnItemRemoved?.Invoke(this, null);
 }
Exemplo n.º 27
0
 public void RemoveItem(Item item)
 {
     _items.Remove(item);
     OnItemRemoved?.Invoke(item);
 }
Exemplo n.º 28
0
 public void Remove(T item)
 {
     OnItemRemoved?.Invoke(this, new ListEventArgs("ItemRemoved event fired.", _list.Count));
     _list.Remove(item);
 }
Exemplo n.º 29
0
 public void RemoveSlot(InventorySlot slot)
 {
     items.Remove(slot);
     OnItemRemoved?.Invoke();
 }
Exemplo n.º 30
0
 public void ItemRemovedEvent(ItemInstance itemInstance) => OnItemRemoved?.Invoke(itemInstance);