예제 #1
0
        /// <summary>
        /// Remove first instance of a business object from the collection
        /// </summary>
        /// <param name="BusinessObject"></param>
        /// <returns></returns>
        public virtual bool Remove(Func <T, bool> predicate)
        {
            bool result = false;

            //loop through the inner array's indices
            for (int i = 0; i < _innerArray.Count; i++)
            {
                //store current index being checked
                T obj = _innerArray[i];

                //compare the BusinessObjectBase UniqueId property
                if (predicate(obj))
                {
                    //remove item from inner ArrayList at index i
                    _innerArray.RemoveAt(i);

                    result = true;
                    break;
                }
            }

            if (result)
            {
                if (ItemArrayChanged != null)
                {
                    ItemArrayChanged.Invoke();
                }
            }

            return(result);
        }
예제 #2
0
 /// <summary>
 /// Inserts an item to the <see cref="T:System.Collections.Generic.IList`1"/> 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 into the <see cref="T:System.Collections.Generic.IList`1"/>.</param><exception cref="T:System.ArgumentOutOfRangeException"><paramref name="index"/> is not a valid index in the <see cref="T:System.Collections.Generic.IList`1"/>.</exception><exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.IList`1"/> is read-only.</exception>
 public void Insert(int index, T item)
 {
     _innerArray.Insert(index, item);
     if (ItemArrayChanged != null)
     {
         ItemArrayChanged.Invoke();
     }
 }
예제 #3
0
 /// <summary>
 /// Clear the collection of all it's elements
 /// </summary>
 public virtual void Clear()
 {
     _innerArray.Clear();
     if (ItemArrayChanged != null)
     {
         ItemArrayChanged.Invoke();
     }
 }
예제 #4
0
 /// <summary>
 /// Add a business object to the collection
 /// </summary>
 /// <param name="BusinessObject"></param>
 public virtual void Add(T BusinessObject)
 {
     _innerArray.Add(BusinessObject);
     if (ItemArrayChanged != null)
     {
         ItemArrayChanged.Invoke();
     }
 }
예제 #5
0
        public bool Remove(T item)
        {
            var result = _innerArray.Remove(item);

            if (result)
            {
                if (ItemArrayChanged != null)
                {
                    ItemArrayChanged.Invoke();
                }
            }
            return(result);
        }
예제 #6
0
        /// <summary>
        /// Add a business object to the collection
        /// </summary>
        /// <param name="BusinessObjects"></param>
        public virtual void AddRange(IList <T> BusinessObjects)
        {
            var result = false;

            foreach (var businessObject in BusinessObjects)
            {
                _innerArray.Add(businessObject);
                result = true;
            }

            if (result)
            {
                if (ItemArrayChanged != null)
                {
                    ItemArrayChanged.Invoke();
                }
            }
        }