C# Class Open.Core.Helpers.CollectionHelper

Utility methods for working with collections.
Mostra file Open project: philcockfield/Open.TestHarness.SL

Public Methods

Method Description
Count ( IEnumerable collection ) : int

Gets the total number of items within the given collection.

DisposeAndClear ( ArrayList collection ) : void

Clears the collection, disposing of all disposable children.

Filter ( IEnumerable collection, FuncBool predicate ) : ArrayList

Constructs a subset of the collection based on the response of an include-filter.

First ( IEnumerable collection, FuncBool predicate ) : object

Retrieves the first item that matches the given filter (or null if there is no match).

Last ( IEnumerable collection ) : object

Retrieves the last item in the given collection (or null if there are no items).

ToArrayList ( IEnumerable collection ) : ArrayList

Converts an enumerable to an ArrayList.

Total ( IEnumerable collection, FuncBool predicate ) : int

Gets the total number of items that match the given predicate.

Method Details

Count() public method

Gets the total number of items within the given collection.
public Count ( IEnumerable collection ) : int
collection IEnumerable The collection to count.
return int

DisposeAndClear() public method

Clears the collection, disposing of all disposable children.
public DisposeAndClear ( ArrayList collection ) : void
collection System.Collections.ArrayList The collection to clear and dispose.
return void

Filter() public method

Constructs a subset of the collection based on the response of an include-filter.
public Filter ( IEnumerable collection, FuncBool predicate ) : ArrayList
collection IEnumerable The collection to filter.
predicate FuncBool The predicate to match.
return System.Collections.ArrayList

First() public method

Retrieves the first item that matches the given filter (or null if there is no match).
public First ( IEnumerable collection, FuncBool predicate ) : object
collection IEnumerable The collection to examine.
predicate FuncBool The predicate to match.
return object

Last() public method

Retrieves the last item in the given collection (or null if there are no items).
public Last ( IEnumerable collection ) : object
collection IEnumerable The collection to examine.
return object

ToArrayList() public method

Converts an enumerable to an ArrayList.
public ToArrayList ( IEnumerable collection ) : ArrayList
collection IEnumerable The collection to convert.
return System.Collections.ArrayList

Total() public method

Gets the total number of items that match the given predicate.
public Total ( IEnumerable collection, FuncBool predicate ) : int
collection IEnumerable The collection to examine.
predicate FuncBool The predicate to match.
return int