public static EnumerableToArray ( IEnumerable collection, bool alwaysCreate ) : ArrayList | ||
collection | IEnumerable | The source collection |
alwaysCreate | bool | If true, this method will always create a new /// collection. |
return | ArrayList |
/// <summary> /// Build our filtered list from our full list. /// </summary> protected void FilterObjects() { if (!this.listView.UseFiltering || (this.modelFilter == null && this.listFilter == null)) { this.filteredObjectList = new ArrayList(this.fullObjectList); return; } IEnumerable objects = (this.listFilter == null) ? this.fullObjectList : this.listFilter.Filter(this.fullObjectList); // Apply the object filter if there is one if (this.modelFilter == null) { this.filteredObjectList = ObjectListView.EnumerableToArray(objects, false); } else { this.filteredObjectList = new ArrayList(); foreach (object model in objects) { if (this.modelFilter.Filter(model)) { this.filteredObjectList.Add(model); } } } }
/// <summary> /// Build our filtered list from our full list. /// </summary> protected void FilterObjects() { // If this list isn't filtered, we don't need to do anything else if (!this.listView.UseFiltering) { this.filteredObjectList = new ArrayList(this.fullObjectList); return; } // Tell the world to filter the objects. If they do so, don't do anything else // ReSharper disable PossibleMultipleEnumeration FilterEventArgs args = new FilterEventArgs(this.fullObjectList); this.listView.OnFilter(args); if (args.FilteredObjects != null) { this.filteredObjectList = ObjectListView.EnumerableToArray(args.FilteredObjects, false); return; } IEnumerable objects = (this.listFilter == null) ? this.fullObjectList : this.listFilter.Filter(this.fullObjectList); // Apply the object filter if there is one if (this.modelFilter == null) { this.filteredObjectList = ObjectListView.EnumerableToArray(objects, false); } else { this.filteredObjectList = new ArrayList(); foreach (object model in objects) { if (this.modelFilter.Filter(model)) this.filteredObjectList.Add(model); } } }
/// <summary> /// /// </summary> /// <param name="collection"></param> public override void SetObjects(IEnumerable collection) { ArrayList newObjects = ObjectListView.EnumerableToArray(collection, true); this.fullObjectList = newObjects; this.FilterObjects(); this.RebuildIndexMap(); }
/// <summary> /// Create an exporter that will export all the given rows from the given ObjectListView /// </summary> /// <param name="olv"></param> /// <param name="objectsToExport"></param> public OLVExporter(ObjectListView olv, IEnumerable objectsToExport) { if (objectsToExport == null) { throw new ArgumentNullException("objectsToExport"); } this.ListView = olv ?? throw new ArgumentNullException("olv"); this.ModelObjects = ObjectListView.EnumerableToArray(objectsToExport, true); }
/// <summary> /// Return the last N subset of the model objects /// </summary> /// <param name="modelObjects"></param> /// <returns></returns> public override IEnumerable Filter(IEnumerable modelObjects) { if (this.Count <= 0) { return(modelObjects); } ArrayList list = ObjectListView.EnumerableToArray(modelObjects, false); if (this.Count > list.Count) { return(list); } object[] tail = new object[this.Count]; list.CopyTo(list.Count - this.Count, tail, 0, this.Count); return(new ArrayList(tail)); }