Esempio n. 1
0
 public new void Insert(Int32 index, T item)
 {
     base.Insert(index, item);
     OnAdd?.Invoke(ref item);
     OnInsert?.Invoke(index, ref item);
     ItemsChanged?.Invoke();
 }
Esempio n. 2
0
        public void OnDeserializeAll(NetworkReader reader)
        {
            // This list can now only be modified by synchronization
            IsReadOnly = true;

            // if init,  write the full list content
            int count = (int)reader.ReadPackedUInt32();

            objects.Clear();
            OnClear?.Invoke();
            changes.Clear();

            for (int i = 0; i < count; i++)
            {
                T obj = reader.Read <T>();
                objects.Add(obj);
                OnInsert?.Invoke(i, obj);
            }

            // We will need to skip all these changes
            // the next time the list is synchronized
            // because they have already been applied
            changesAhead = (int)reader.ReadPackedUInt32();

            OnChange?.Invoke();
        }
Esempio n. 3
0
        public void Insert(T Data)
        {
            Node <T> before = null, after = this.Root;

            while (after != null)
            {
                before = after;
                if (Data.CompareTo(after.Data) == -1)
                {
                    after = after.Left;
                }
                else
                {
                    after = after.Right;
                }
            }

            Node <T> newNode = new Node <T>(Data);

            if (this.Root == null)
            {
                this.Root = newNode;
            }
            else if (Data.CompareTo(before.Data) == -1)
            {
                before.Left = newNode;
            }
            else
            {
                before.Right = newNode;
            }
            OnInsert?.Invoke(this, new MyTreeEventArgs <T>(newNode.Data));
        }
Esempio n. 4
0
        private void RaiseEvents(Operation op, int itemIndex, T oldItem, T newItem)
        {
            switch (op)
            {
            case Operation.OP_ADD:
                OnInsert?.Invoke(objects.Count - 1, newItem);
                break;

            case Operation.OP_CLEAR:
                OnClear?.Invoke();
                break;

            case Operation.OP_INSERT:
                OnInsert?.Invoke(itemIndex, newItem);
                break;

            case Operation.OP_REMOVEAT:
                OnRemove?.Invoke(itemIndex, oldItem);
                break;

            case Operation.OP_SET:
                OnSet?.Invoke(itemIndex, oldItem, newItem);
                break;
            }
        }
Esempio n. 5
0
        private void WriteToDb()
        {
            while (true)
            {
                try
                {
                    while (DateTime.Now.Second != 0)
                    {
                        Thread.Sleep(TimeSpan.FromMilliseconds(400));
                    }

                    try
                    {
                        new TemperatureFrameDatabaseAdapter().Insert(GetFromQueues());
                    }
                    catch { }
                    OnInsert?.Invoke(this, EventArgs.Empty);
                    Thread.Sleep(TimeSpan.FromSeconds(1));
                }
                catch (ThreadAbortException)
                {
                    break;
                }
            }
        }
Esempio n. 6
0
 public void Insert(string key, object value)
 {
     VerifyInstance();
     _inner.Insert(key, value);
     OnInsert?.Invoke(new CacheEventArgs(CacheOperation.Insert, key,
                                         CacheKeyHelper.GetResourceKeyFromCacheKey(key)));
 }
Esempio n. 7
0
 public new void Insert(int index, T item)
 {
     base.Insert(index, item);
     if (OnInsert != null)
     {
         OnInsert.Invoke(this, new NListEventArgs <T>(item, index));
     }
 }
Esempio n. 8
0
 public new void Add(T item)
 {
     base.Add(item);
     if (OnInsert != null)
     {
         OnInsert.Invoke(this, new NListEventArgs <T>(item, this.Count));
     }
 }
Esempio n. 9
0
        private void DeserializeAdd(NetworkReader reader, bool apply)
        {
            T newItem = reader.Read <T>();

            if (apply)
            {
                objects.Add(newItem);
                OnInsert?.Invoke(objects.Count - 1, newItem);
            }
        }
Esempio n. 10
0
        public void Insert(string key, object value)
        {
            VerifyInstance();

            var resourceKey = CacheKeyHelper.GetResourceKeyFromCacheKey(key);

            _inner.Insert(key, value);
            KnownResourceKeys.TryAdd(resourceKey, null);

            OnInsert?.Invoke(new CacheEventArgs(CacheOperation.Insert, key, resourceKey));
        }
Esempio n. 11
0
        private void DeserializeInsert(NetworkReader reader, bool apply)
        {
            int index   = (int)reader.ReadPackedUInt32();
            T   newItem = reader.Read <T>();

            if (apply)
            {
                objects.Insert(index, newItem);
                OnInsert?.Invoke(index, newItem);
            }
        }
Esempio n. 12
0
        private void DeserializeAdd(NetworkReader reader, bool apply)
        {
            TKey   key  = reader.Read <TKey>();
            TValue item = reader.Read <TValue>();

            if (apply)
            {
                objects[key] = item;
                OnInsert?.Invoke(key, item);
            }
        }
Esempio n. 13
0
        public async Task ForceInsert()
        {
            if (Quene.Count <= 0)
            {
                return;
            }
            OnInsert?.Invoke();
            await Collection.InsertManyAsync(Quene).ConfigureAwait(false);

            Quene.Clear();
        }
Esempio n. 14
0
 public new void InsertRange(int index, IEnumerable <T> collection)
 {
     base.InsertRange(index, collection);
     foreach (var item in collection)
     {
         if (OnInsert != null)
         {
             OnInsert.Invoke(this, new NListEventArgs <T>(item, index));
         }
         index++;
     }
 }
Esempio n. 15
0
 public new void Insert(int index, T item)
 {
     if (OnInsert != null)
     {
         NListInhEventArgs<T> vArgs = new NListInhEventArgs<T>(item, index);
         OnInsert.Invoke(this, vArgs);
         if (vArgs.Inherited)
             base.Insert(index, item);
     }
     else
         base.Insert(index, item);
 }
Esempio n. 16
0
 public new void Add(T item)
 {
     if (OnInsert != null)
     {
         NListInhEventArgs<T> vArgs = new NListInhEventArgs<T>(item, this.Count);
         OnInsert.Invoke(this, vArgs);
         if (vArgs.Inherited)
             base.Add(item);
     }
     else
         base.Add(item);
 }
Esempio n. 17
0
 public new void AddRange(IEnumerable<T> collection)
 {
     Int32 Index = base.Count;
     base.AddRange(collection);
     foreach (var item in collection)
     {
         if (OnInsert != null)
         {
             OnInsert.Invoke(this, new NListEventArgs<T>(item, Index));
         }
         Index++;
     }
 }
        public void Insert(string key, object value, bool insertIntoKnownResourceKeys)
        {
            VerifyInstance();

            _inner.Insert(key.ToLower(), value, insertIntoKnownResourceKeys);
            var resourceKey = CacheKeyHelper.GetResourceKeyFromCacheKey(key);

            if (insertIntoKnownResourceKeys)
            {
                _knownResourceKeys.TryAdd(resourceKey, null);
            }

            OnInsert?.Invoke(new CacheEventArgs(CacheOperation.Insert, key, resourceKey));
        }
Esempio n. 19
0
        /// <summary>
        /// Inserts a string into the string table at a zero-based index position.
        /// </summary>
        public static int Insert(int index, string str)
        {
            SampleCsStringTable string_table = SampleCsStringTable.Instance;
            int rc = string_table.Insert(index, str);

            if (rc >= 0)
            {
                // Invoke event
                if (null != OnInsert)
                {
                    OnInsert.Invoke(index, str);
                }
            }
            return(rc);
        }
Esempio n. 20
0
        public new void InsertRange(int index, IEnumerable<T> collection)
        {
            if (OnInsert != null)
            {
                foreach (var item in collection)
                {
                    NListInhEventArgs<T> vArgs = new NListInhEventArgs<T>(item, index);
                    OnInsert.Invoke(this, vArgs);
                    if (vArgs.Inherited)
                        base.Insert(index, item);

                    index++;
                }
            }
            else
                base.InsertRange(index, collection);
        }
Esempio n. 21
0
        ///<inheritdoc/>
        public void Insert(int index, T item)
        {
            index = IndexProcessor(_len, index);
            int insertIndex = index;

            if (insertIndex != _arr.Length - 1)
            {
                EnsureCapacity(_len + 2, false);
                Array.Copy(_arr, insertIndex, _arr, insertIndex + 1, _len - insertIndex);
                _arr[insertIndex] = item;
                _len++;
            }
            else
            {
                Add(item);
            }
            OnInsert?.Invoke(item, index);
            _len++;
        }
Esempio n. 22
0
        private void RaiseEvents(Operation op, TKey key, TValue value, TValue oldValue)
        {
            switch (op)
            {
            case Operation.OP_ADD:
                OnInsert?.Invoke(key, value);
                break;

            case Operation.OP_CLEAR:
                OnClear?.Invoke();
                break;

            case Operation.OP_REMOVE:
                OnRemove?.Invoke(key, value);
                break;

            case Operation.OP_SET:
                OnSet?.Invoke(key, oldValue, value);
                break;
            }
        }
Esempio n. 23
0
        public virtual void Add(T item)
        {
            lock (Items)
            {
                if (item == null)
                {
                    throw new ArgumentNullException("Item cant be null");
                }

                if (Items.Contains(item))
                {
                    throw new ArgumentException("Item is already part of this collection");
                }

                // Control einfügen
                Items.Add(item);

                // Event werfen
                OnInsert?.Invoke(item, Items.IndexOf(item));
            }
        }
Esempio n. 24
0
        public new void AddRange(IEnumerable <T> collection)
        {
            Int32 index = base.Count;

            if (OnInsert != null)
            {
                foreach (var item in collection)
                {
                    NListInhEventArgs <T> vArgs = new NListInhEventArgs <T>(item, index);
                    OnInsert.Invoke(this, vArgs);
                    if (vArgs.Inherited)
                    {
                        base.Insert(index, item);
                    }

                    index++;
                }
            }
            else
            {
                base.AddRange(collection);
            }
        }
Esempio n. 25
0
 protected void RaiseOnInsert(T t) => OnInsert?.Invoke(t);
 public void Add(T data)
 {
     OnInsert?.Invoke(this, new BinaryTreeEventArgs <T>(data));
     Add(new Node <T>(data));
 }
Esempio n. 27
0
 public void Add(T item)
 {
     objects.Add(item);
     OnInsert?.Invoke(objects.Count - 1, item);
     AddOperation(Operation.OP_ADD, objects.Count - 1, item);
 }
Esempio n. 28
0
 public void Insert(Int32 index, GenericListViewItem <T> item)
 {
     _items.Insert(index, item ?? throw new ArgumentNullException(nameof(item)));
     OnInsert?.Invoke(index, ref item);
     ItemsChanged?.Invoke();
 }