Beispiel #1
0
 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])));
 }
Beispiel #2
0
 public static Quantifier All <T>(ElementTypePredicate <T> pred)
 {
     return((IEnumerable <object> elems) => elems.All(e => pred(e)));
 }
Beispiel #3
0
 public static Quantifier Count <T>(ElementTypePredicate <T> pred, int count)
 {
     return((IEnumerable <object> elems) => elems.Count(e => pred(e)) == count);
 }
Beispiel #4
0
        // 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));
        }
Beispiel #5
0
 public IEnumerable <T> Get <T>(ElementTypePredicate <T> pred)
 {
     return(elems.Where(e => pred(e)).Cast <T>());
 }
Beispiel #6
0
 public Quantifier BindPositionQuantifier <T>(ElementTypePredicate <T> pred,
                                              params int[] positions)
 {
     return(Quantifiers.Position(pred, elemPositions, positions));
 }
Beispiel #7
0
 public T Get <T>(ElementTypePredicate <T> pred)
 {
     return((T)elems.Single(e => pred(e)));
 }
Beispiel #8
0
 public void Add <T>(ElementTypePredicate <T> pred, object elem)
 {
     Add(pred.ToPredicate(), elem);
 }