예제 #1
0
        /// <summary>
        /// Finds all distinct elements for the specified column
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <returns></returns>
        public virtual VList <T> FindAllDistinct(string columnName)
        {
            PropertyDescriptorCollection props    = TypeDescriptor.GetProperties(typeof(T));
            PropertyDescriptor           filterBy = props.Find(columnName, true);
            VList <T> result = new VList <T>();

            object a;
            object b;
            bool   found;

            foreach (T item in this)
            {
                a     = filterBy.GetValue(item);
                found = false;

                foreach (T item2 in result)
                {
                    b = filterBy.GetValue(item2);
                    if ((a == null && b == null) ||
                        (a != null && b != null && a.Equals(b)))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    result.Add(item);
                }
            }

            return(result);
        }
예제 #2
0
        ///<summary>
        /// Creates an exact copy of this VList{T} object.
        ///</summary>
        ///<returns>A new, identical copy of the VList{T}.</returns>
        public virtual VList <T> Copy()
        {
            VList <T> copy = new VList <T>();

            foreach (T item in this)
            {
                T itemCopy = (T)MakeCopyOf(item);
                copy.Add(itemCopy);
            }
            return(copy);
        }
예제 #3
0
        ///<summary>
        /// Finds a collection of <see cref="IEntity" /> objects in the current list matching the search criteria.
        ///</summary>
        /// <param name="findAllByType"><see cref="FindAllByType" /> Type to easily search by</param>
        /// <param name="propertyName">Property of the object to search.</param>
        /// <param name="value">Value to find.</param>
        /// <param name="ignoreCase">A Boolean indicating a case-sensitive or insensitive comparison (true indicates a case-insensitive comparison).  String properties only.</param>
        public virtual VList <T> FindAllBy(FindAllByType findAllByType, string propertyName, object value, bool ignoreCase)
        {
            PropertyDescriptorCollection props    = base.PropertyCollection;
            PropertyDescriptor           searchBy = props.Find(propertyName, true);

            VList <T> result = new VList <T>();

            int index = 0;

            while (index > -1)
            {
                index = this.FindAllBy(findAllByType, searchBy, value, index, ignoreCase);

                if (index > -1)
                {
                    result.Add(this[index]);

                    //Increment the index to start at the next item
                    index++;
                }
            }

            return(result);
        }