public static Quantifier Position <T>(ElementTypePredicate <T> pred, Dictionary <int, object> positionsMap, params int[] positions) { return((IEnumerable <object> elems) => positions.All(p => positionsMap.ContainsKey(p) && pred(positionsMap[p]))); }
public static Quantifier All <T>(ElementTypePredicate <T> pred) { return((IEnumerable <object> elems) => elems.All(e => pred(e))); }
public static Quantifier Count <T>(ElementTypePredicate <T> pred, int count) { return((IEnumerable <object> elems) => elems.Count(e => pred(e)) == count); }
// Delegates which operate on typed elements can't be stored -- for those delegates, we implement // conversions to equivalent ones which operate on untyped elements public static Predicate ToPredicate <T>(this ElementTypePredicate <T> elemTypePred) { return(new Predicate((object e) => e is T)); }
public IEnumerable <T> Get <T>(ElementTypePredicate <T> pred) { return(elems.Where(e => pred(e)).Cast <T>()); }
public Quantifier BindPositionQuantifier <T>(ElementTypePredicate <T> pred, params int[] positions) { return(Quantifiers.Position(pred, elemPositions, positions)); }
public T Get <T>(ElementTypePredicate <T> pred) { return((T)elems.Single(e => pred(e))); }
public void Add <T>(ElementTypePredicate <T> pred, object elem) { Add(pred.ToPredicate(), elem); }