Example #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="descriptionCollection"></param>
 public void ApplySort(ListSortDescriptionCollection descriptionCollection)
 {
     _logger.Log("ApplySort - ListSortDescriptionCollection ", LogCategory.Info);
     SortDescriptions = descriptionCollection;
     ViewOfBusinessObjectCollection.Sort(new GenericComparer <T>(SortDescriptions));
     OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
 }
Example #2
0
        /// <summary>
        /// Removes the first occurrence of a specific object from the <see cref="IBusinessObjectCollection"/>.
        /// </summary>
        /// <param name="value">The object to remove from the <see cref="IBusinessObjectCollection"/>.</param>
        public void Remove(object value)
        {
            var index = IndexOf(value);

            ViewOfBusinessObjectCollection.Remove((T)value);
            FireListChanged(ListChangedType.ItemDeleted, index);
        }
Example #3
0
        /// <summary>
        /// Determines whether the <see cref="IBusinessObjectCollection"/> contains a specific <see cref="BusinessObject"/>.
        /// </summary>
        /// <param name="value">The object to locate in the collection.</param>
        /// <returns>True if the object is found in the collection; otherwise, false.</returns>
        public bool Contains(object value)
        {
            _logger.Log("Contains : " + value + " ", LogCategory.Info);
            T bo = (T)value;

            return(ViewOfBusinessObjectCollection.Contains(bo));
        }
Example #4
0
        /// <summary>
        /// Removes the first occurrence of a specific object from the <see cref="IBusinessObjectCollection"/>.
        /// </summary>
        /// <param name="value">The object to remove from the <see cref="IBusinessObjectCollection"/>.</param>
        public void Remove(object value)
        {
            _logger.Log("Remove : " + value + " ", LogCategory.Info);
            var index = IndexOf(value);

            ViewOfBusinessObjectCollection.Remove((T)value);
            OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index, index));
        }
Example #5
0
        /// <summary>
        /// Inserts an object to the <see cref="IBusinessObjectCollection"/> at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which value should be inserted.</param>
        /// <param name="value">The object to insert into the collection.</param>
        public void Insert(int index, object value)
        {
            if (value != null && !typeof(T).IsAssignableFrom(value.GetType()))
            {
                throw new HabaneroArgumentException("Given instance doesn't match needed type.");
            }

            ViewOfBusinessObjectCollection.Insert(index, (T)value);
            BusinessObjectCollection.Insert(index, (T)value);
            FireListChanged(ListChangedType.ItemAdded, index);
        }
Example #6
0
        /// <summary>
        /// Inserts an object to the <see cref="IBusinessObjectCollection"/> at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which value should be inserted.</param>
        /// <param name="value">The object to insert into the collection.</param>
        public void Insert(int index, object value)
        {
            if (value != null && !typeof(T).IsAssignableFrom(value.GetType()))
            {
                throw new HabaneroArgumentException("Given instance doesn't match needed type.");
            }

            _logger.Log("Insert Index : " + index + " value : " + value, LogCategory.Info);
            ViewOfBusinessObjectCollection.Insert(index, (T)value);
            BusinessObjectCollection.Insert(index, (T)value);
            OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
        }
Example #7
0
        /// <summary>
        /// Returns the index of the row that has the given <see cref="T:System.ComponentModel.PropertyDescriptor"/>.
        /// </summary>
        /// <returns>
        /// The index of the row that has the given <see cref="T:System.ComponentModel.PropertyDescriptor"/>.
        /// </returns>
        /// <param name="property">The <see cref="T:System.ComponentModel.PropertyDescriptor"/> to search on. </param>
        /// <param name="key">The value of the <paramref name="property"/> parameter to search for.</param>
        public int Find(PropertyDescriptor property, object key)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            var foundBO = ViewOfBusinessObjectCollection.Find(obj => obj.GetPropertyValue(property.Name) == key);

            if (foundBO == null)
            {
                return(-1);
            }
            return(ViewOfBusinessObjectCollection.IndexOf(foundBO));
        }
Example #8
0
 /// <summary>
 /// Copies the objects of the <see cref="IBusinessObjectCollection"/> to an <see cref="Array"/>,
 /// starting at a particular <see cref="Array"/> index.
 /// </summary>
 /// <param name="array">
 /// The one-dimensional <see cref="Array"/> that is the destination of the objects copied from
 /// <see cref="IBusinessObjectCollection"/>. The <see cref="Array"/> must have zero-based indexing.
 /// </param>
 /// <param name="index">The zero-based index in array at which copying begins.</param>
 public void CopyTo(Array array, int index)
 {
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     if (index >= array.Length)
     {
         throw new ArgumentException("index");
     }
     if (ViewOfBusinessObjectCollection != null)
     {
         ViewOfBusinessObjectCollection.CopyTo(array, index);
     }
 }
Example #9
0
        /// <summary>
        /// Returns the index of the row that has the given <see cref="T:System.ComponentModel.PropertyDescriptor"/>.
        /// </summary>
        /// <returns>
        /// The index of the row that has the given <see cref="T:System.ComponentModel.PropertyDescriptor"/>.
        /// </returns>
        /// <param name="property">The <see cref="T:System.ComponentModel.PropertyDescriptor"/> to search on. </param>
        /// <param name="key">The value of the <paramref name="property"/> parameter to search for.</param>
        public int Find(PropertyDescriptor property, object key)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            _logger.Log("Find : " + property.Name + " value : " + key, LogCategory.Info);
            var foundBO = ViewOfBusinessObjectCollection.Find(obj => obj.GetPropertyValue(property.Name) == key);

            if (foundBO == null)
            {
                return(-1);
            }
            return(ViewOfBusinessObjectCollection.IndexOf(foundBO));
        }
Example #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="descriptionCollection"></param>
 public void ApplySort(ListSortDescriptionCollection descriptionCollection)
 {
     SortDescriptions = descriptionCollection;
     ViewOfBusinessObjectCollection.Sort(new GenericComparer <T>(SortDescriptions));
     FireListChanged(ListChangedType.Reset);
 }
Example #11
0
 /// <summary>
 /// Determines the index of a specific item in the <see cref="IBusinessObjectCollection"/>.
 /// </summary>
 /// <param name="value">The object to locate in the collection.</param>
 /// <returns>The index of value if found in the list; otherwise, -1.</returns>
 public int IndexOf(object value)
 {
     return(ViewOfBusinessObjectCollection.IndexOf((T)value));
 }
Example #12
0
        /// <summary>
        /// Determines whether the <see cref="IBusinessObjectCollection"/> contains a specific <see cref="BusinessObject"/>.
        /// </summary>
        /// <param name="value">The object to locate in the collection.</param>
        /// <returns>True if the object is found in the collection; otherwise, false.</returns>
        public bool Contains(object value)
        {
            T bo = (T)value;

            return(ViewOfBusinessObjectCollection.Contains(bo));
        }
Example #13
0
 /// <summary>
 /// Removes the <see cref="IBusinessObjectCollection"/> item at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index of the item to remove.</param>
 public void RemoveAt(int index)
 {
     _logger.Log("RemoveAt : " + index + " ", LogCategory.Info);
     ViewOfBusinessObjectCollection.RemoveAt(index);
     OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
 }
Example #14
0
 /// <summary>
 /// Determines the index of a specific item in the <see cref="IBusinessObjectCollection"/>.
 /// </summary>
 /// <param name="value">The object to locate in the collection.</param>
 /// <returns>The index of value if found in the list; otherwise, -1.</returns>
 public int IndexOf(object value)
 {
     _logger.Log("IndexOf : " + value + " ", LogCategory.Info);
     return(ViewOfBusinessObjectCollection.IndexOf((T)value));
 }
Example #15
0
 /// <summary>
 /// Removes all items from the <see cref="IList"/>.
 /// </summary>
 public void Clear()
 {
     _logger.Log("Clear ", LogCategory.Info);
     ViewOfBusinessObjectCollection.Clear();
     OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, 0));
 }