public static IEnumerable <T> Search <T>(this IEnumerable <T> list, IItemSearchCriteria <T> productSearchCriteria) { foreach (var item in list) { var tItem = (T)item; if (productSearchCriteria.isSatisfiedBy(tItem)) { yield return(tItem); } } }
public MyCollection <T> Search(IItemSearchCriteria <T> productSearchCriteria) { var result = new MyCollection <T>(); foreach (var item in _list) { var tItem = (T)item; if (productSearchCriteria.isSatisfiedBy(tItem)) { result.Add(tItem); } } return(result); }
public bool isSatisfiedBy(T item) { return(!_searchCriteria.isSatisfiedBy(item)); }