Exemplo n.º 1
0
        private static bool MatchPredicate(PackageModel packageModel, BinaryPredicate predicate)
        {
            var expr1 = predicate.Operand1 as Expression;

            switch (predicate.Operator)
            {
                case Operator.OR:
                    return Match(packageModel, predicate.Operand1) || Match(packageModel, predicate.Operand2);
                case Operator.AND:
                    return Match(packageModel, predicate.Operand1) && Match(packageModel, predicate.Operand2);
                case Operator.EQUAL:
                case Operator.NOTEQUAL:
                case Operator.GREATERTHAN:
                case Operator.LESSTHAN:
                case Operator.GREATERTHANOREQUAL:
                case Operator.LESSTHANOREQUAL:
                    if (expr1 != null)
                    {
                        switch (expr1.Value)
                        {
                            case "version": return MatchVersion(packageModel, predicate);
                            case "arch": return MatchArchitecture(packageModel, predicate);
                        }
                    }
                    break;
            }

            return true;
        }
Exemplo n.º 2
0
        private static bool MatchArchitecture(PackageModel packageModel, BinaryPredicate predicate)
        {
            var expr2 = predicate.Operand2 as Expression;

            if (expr2 != null)
            {
                switch (predicate.Operator)
                {
                    case Operator.EQUAL: return packageModel.Architecture == expr2.Value;
                    case Operator.NOTEQUAL: return packageModel.Architecture != expr2.Value;
                }
            }

            return true;
        }
Exemplo n.º 3
0
        private static bool MatchVersion(PackageModel packageModel, BinaryPredicate predicate)
        {
            var expr2 = predicate.Operand2 as Expression;

            if (expr2 != null)
            {
                switch (predicate.Operator)
                {
                    case Operator.EQUAL:               return packageModel.Package.Version == expr2.Value;
                    case Operator.NOTEQUAL:            return packageModel.Package.Version != expr2.Value;
                    case Operator.GREATERTHAN:         return packageModel.Package.Version > expr2.Value;
                    case Operator.LESSTHAN:            return packageModel.Package.Version < expr2.Value;
                    case Operator.GREATERTHANOREQUAL:  return packageModel.Package.Version >= expr2.Value;
                    case Operator.LESSTHANOREQUAL:     return packageModel.Package.Version <= expr2.Value;
                }
            }

            return true;
        }