Пример #1
0
        /// <summary>Inserts an element into the list at the specified index.</summary>
        /// <param name="index">The zero-based index at which <paramref name="item" /> should be inserted.</param>
        /// <param name="item">The object to insert. The value can be null for reference types.</param>
        public void Insert(int index, [CanBeNull] T item)
        {
            var success = EventsEnabled ? BeforeAdding.Call(this, index, item, true) : true;

            if (success)
            {
                _list.Insert(index, item);
                if (EventsEnabled)
                {
                    Added.Call(this, index, item);
                }
            }
        }
Пример #2
0
        /// <summary>Adds an object to the end of the list.</summary>
        /// <param name="item">
        ///     The object to be added to the end of the list. The value can be null for
        ///     reference types.
        /// </param>
        public void Add([CanBeNull] T item)
        {
            var index   = Count;
            var success = EventsEnabled ? BeforeAdding.Call(this, index, item, true) : true;

            if (success)
            {
                _list.Add(item);
                if (EventsEnabled)
                {
                    Added.Call(this, index, item);
                }
            }
        }