示例#1
0
 public BindingListView()
     : base()
 {
     this.data             = new List <T>();
     manager               = new DataManager <T>();
     this.filterCollection = new FilterSpecCollection();
 }
示例#2
0
 public BindingListView(IList <T> data)
     : base(data)
 {
     this.data             = new List <T>();
     this.manager          = new DataManager <T>();
     this.filterCollection = new FilterSpecCollection();
     foreach (T obj in data)
     {
         data.Add(obj);
         manager.Add(obj);
     }
 }
示例#3
0
 public FilterSpecCollection(FilterSpecCollection filterlist)
     : base(filterlist)
 {
 }
示例#4
0
        private void Refresh()
        {
            FilterSpec fSpec = new FilterSpec(filter);

            //count = this.Count;
            //for (int i = 0; i < count; i++)
            //{
            //    PropertyInfo prop = typeof(T).GetProperty(spec.Subject);
            //    while (i < count && Belongs(this[i], spec))
            //    {
            //        //bad
            //        this.Remove(this[i]);
            //        count = this.Count;
            //    }
            //}
            //for (int i = 0; i < this.data.Count; i++)
            //{
            //    if (!this.Belongs(this.data[i], spec))
            //        base.Add(this.data[i]);
            //}
            lock (this)
            {
                List <T> filteredItems = new List <T>();
                try
                {
                    FilterSpecCollection specs = new FilterSpecCollection(this.filterCollection);
                    specs.Add(fSpec);
                    int counter = 0;
                    foreach (FilterSpec spec in specs)
                    {
                        if (counter == 0)
                        {
                            foreach (KeyValuePair <long, T> kvp in this.manager)
                            {
                                if (this.Belongs(kvp.Value, spec))
                                {
                                    filteredItems.Add(kvp.Value);
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < filteredItems.Count; i++)
                            {
                                if (!this.Belongs(filteredItems[i], spec))
                                {
                                    filteredItems.RemoveAt(i--);
                                }
                            }
                        }
                        counter++;
                    }

                    this.ClearItems();
                    filteredItems.ForEach(delegate(T item)
                    {
                        base.Add(item);
                    });
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }