コード例 #1
0
        /// <summary>
        /// Build our filtered list from our full list.
        /// </summary>
        protected void FilterObjects()
        {
            if (!listView.UseFiltering || (modelFilter == null && listFilter == null))
            {
                filteredObjectList = new ArrayList(fullObjectList);
                return;
            }

            IEnumerable objects = (listFilter == null)
                                      ? fullObjectList
                                      : listFilter.Filter(fullObjectList);

            // Apply the object filter if there is one
            if (modelFilter == null)
            {
                filteredObjectList = ObjectListView.EnumerableToArray(objects, false);
            }
            else
            {
                filteredObjectList = new ArrayList();
                foreach (object model in objects)
                {
                    if (modelFilter.Filter(model))
                    {
                        filteredObjectList.Add(model);
                    }
                }
            }
        }
コード例 #2
0
        private void Populate(TreeListView treeView, IEnumerable objects, IModelFilter filter)
        {
            if (objects == null)
            {
                return;
            }

            foreach (var obj in objects)
            {
                if (treeView.ChildrenGetter != null)
                {
                    Populate(treeView, treeView.ChildrenGetter(obj), filter);
                }

                if (!filter.Filter(obj))
                {
                    continue;
                }

                var matched = obj;
                while (matched != null)
                {
                    _objects.Add(matched);
                    matched = (matched as IDataObjectChild)?.Parent;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Filters the source collection using the passed query parameters.
        /// </summary>
        /// <param name="source">The source items to filter.</param>
        /// <param name="filter">The filter to apply.</param>
        /// <typeparam name="T">The <see cref="Type"/> of items in the source collection.</typeparam>
        /// <returns>A filtered and projected enumeration of the source collection.</returns>
        public static IQueryable <object> Filter <T>(this IEnumerable <T> source, IModelFilter <T> filter)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(filter == null?source.OfType <object>().AsQueryable() : filter.Filter(source));
        }
コード例 #4
0
        /// <summary>
        /// Do the actual work of filtering
        /// </summary>
        /// <param name="objects"></param>
        /// <param name="aModelFilter"></param>
        /// <param name="aListFilter"></param>
        /// <returns></returns>
        protected virtual IEnumerable FilterObjects(IEnumerable objects, IModelFilter aModelFilter, IListFilter aListFilter)
        {
            // Being cautious
            objects = objects ?? new ArrayList();

            // Tell the world to filter the objects. If they do so, don't do anything else
            FilterEventArgs args = new FilterEventArgs(objects);
            this.OnFilter(args);
            if (args.FilteredObjects != null)
                return args.FilteredObjects;

            // Apply a filter to the list as a whole
            if (aListFilter != null)
                objects = aListFilter.Filter(objects);

            // Apply the object filter if there is one
            if (aModelFilter != null) {
                ArrayList filteredObjects = new ArrayList();
                foreach (object model in objects) {
                    if (aModelFilter.Filter(model))
                        filteredObjects.Add(model);
                }
                objects = filteredObjects;
            }

            return objects;
        }
コード例 #5
0
        /// <summary>
        /// Filters the source collection using the passed query parameters.
        /// </summary>
        /// <param name="source">The source items to filter.</param>
        /// <param name="filter">The filter to apply.</param>
        /// <typeparam name="T">The <see cref="Type"/> of items in the source collection.</typeparam>
        /// <returns>A filtered and projected enumeration of the source collection.</returns>
        public static IQueryable <object> Filter <T>(this IEnumerable <T> source, IModelFilter <T> filter)
        {
            Contract.Requires <ArgumentNullException>(source != null);

            return(filter == null?source.OfType <object>().AsQueryable() : filter.Filter(source));
        }
コード例 #6
0
ファイル: FinderBase.cs プロジェクト: mariocosmi/Worker
 private void FillArray(ArrayList vett, IDataReader rdr, System.Type type, IModelFilter modelFilter, Map fieldNames)
 {
     while (rdr != null && rdr.Read()) {
         ModelBase instance = ModelHelper.Instance.New(type, rdr);
         FilterResult stat = (modelFilter == null) ? FilterResult.Accept : modelFilter.Filter(vett, instance, fieldNames);
         if (stat == FilterResult.Accept)
             vett.Add(instance);
         else if (stat == FilterResult.Stop)
             break;
     }
     Logger.DebugFormat("{0} carica {1} records", this.GetType().Name, vett.Count);
 }
コード例 #7
0
 /// <summary>
 /// Filters the source collection using the passed query parameters.
 /// </summary>
 /// <param name="source">The source items to filter.</param>
 /// <param name="filter">The filter to apply.</param>
 /// <typeparam name="T">The <see cref="Type"/> of items in the source collection.</typeparam>
 /// <returns>A filtered and projected enumeration of the source collection.</returns>
 public static IQueryable <object> Filter <T>(this IEnumerable <T> source, IModelFilter <T> filter)
 {
     return(filter == null?source.OfType <object>().AsQueryable() : filter.Filter(source));
 }