Exemplo n.º 1
0
        public override IEnumerable <T> ApplyFilter(IEnumerable <T> source)
        {
            IEnumerable <T> result = source;

            result = result.Where(x => Predicates.Any(y => y(x) == true));

            return(result);
        }
        /// <summary>
        /// Returns exception name that could be used for current non-generic requires.
        /// </summary>
        public IClrTypeName PotentialGenericVersionException()
        {
            Contract.Requires(!IsGenericRequires);
            Contract.Ensures(Contract.Result <IClrTypeName>() != null);

            if (Predicates.Any(n => n.ChecksForNotNull()))
            {
                return(new ClrTypeName(typeof(ArgumentNullException).FullName));
            }

            return(new ClrTypeName(typeof(ArgumentException).FullName));
        }
Exemplo n.º 3
0
        protected bool Filter(Tweet tweet)
        {
            if (Predicates.Count() == 0)
            {
                return(true);
            }

            if (IsOrSearch.Value)
            {
                return(Predicates.Any(predicate => predicate(tweet)));
            }
            else
            {
                return(Predicates.All(predicate => predicate(tweet)));
            }
        }
        public void Evaluate()
        {
            if (Evaluated) return;

            foreach (var predicate in Predicates)
            {
                if (predicate.GetMissingVariableId() != null) continue;

                predicate.Evaluate();

                if (predicate.Result) continue;

                Result = false;
                Evaluated = true;
                return;
            }

            if (Predicates.Any(_ => _.Evaluated && !_.Result) || Predicates.All(_ => _.Evaluated))
            {
                Result = true;
                Evaluated = true;
            }
        }
 public bool ChecksForNotNull(string name)
 {
     return(Predicates.Any(p => p.ChecksForNotNull(name)));
 }
 public bool ChecksForNotNull(string name)
 {
     // For if-throw precondition check should be inverted!
     // That's why IsNotNull assertion means check for null
     return(Predicates.Any(p => p.ChecksForNull(name)));
 }
Exemplo n.º 7
0
 protected override bool RecalculateValue()
 {
     return(Predicates.Any(i => i.Value));
 }
Exemplo n.º 8
0
 /// <summary>Check if any predicate is true</summary>
 public bool CheckAny(T item)
 {
     return(Predicates.Any(predicate => predicate(item)));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Evaluate this predicate for the given loc.
 /// </summary>
 public override bool Evaluate(ILoc loc)
 {
     return(Predicates.Any(x => x.Evaluate(loc)));
 }