public IEnumerable <Product> Filter(IEnumerable <Product> products, IProductSpecification specification) { foreach (var item in products) { if (specification.isSatisfied(item)) { yield return(item); } } }
public bool isSatisfied(Product p) { return(spec1.isSatisfied(p) && spec2.isSatisfied(p)); }