Beispiel #1
0
        private static bool MatchPredicate(PackageItem package, BinaryPredicate predicate)
        {
            var expr1 = predicate.Operand1 as Expression;

            switch (predicate.Operator)
            {
                case Operator.Or:
                    return Match(package, predicate.Operand1) || Match(package, predicate.Operand2);
                case Operator.And:
                    return Match(package, predicate.Operand1) && Match(package, 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(package, predicate);
                        }
                    }
                    break;
            }

            return true;
        }
Beispiel #2
0
 public PropertiesViewModel(PackageItem packageItem)
 {
     DisplayName = "Properties";
     PackageItem = packageItem;
     CloseCommand = new RelayCommand(TryClose);
     GetFiles();
 }
Beispiel #3
0
        internal static bool Match(PackageItem package, IOperand operand)
        {
            var expression = operand as Expression;

            if (expression != null)
                return MatchExpression(package, expression);
            return MatchPredicate(package, operand);
        }
Beispiel #4
0
        private static bool MatchPredicate(PackageItem package, UnaryPredicate predicate)
        {
            switch (predicate.Operator)
            {
                case Operator.Not:
                    return !Match(package, predicate.Operand);
            }

            return true;
        }
Beispiel #5
0
        private static bool MatchExpression(PackageItem package, Expression expression)
        {
            switch (expression.Value)
            {
                case "installed": return package.IsInstalled;
                case "updatable": return package.PackageIdentity.Flags.Count(n => n == "updatable") != 0;
                case "latest": return package.IsLatest;
            }

            return package.Name.ToLowerInvariant().Contains(expression.Value.ToLowerInvariant());
        }
Beispiel #6
0
        private static bool MatchPredicate(PackageItem package, IOperand predicate)
        {
            var unaryPredicate = predicate as UnaryPredicate;
            if (unaryPredicate != null)
                return MatchPredicate(package, unaryPredicate);

            var binaryPredicate = predicate as BinaryPredicate;
            if (binaryPredicate != null)
                return MatchPredicate(package, binaryPredicate);

            return true;
        }
Beispiel #7
0
        private static bool MatchVersion(PackageItem package, BinaryPredicate predicate)
        {
            var expr2 = predicate.Operand2 as Expression;

            if (expr2 != null)
            {
                try
                {
                    switch (predicate.Operator)
                    {
                        case Operator.Equal: return AsVersion(package.PackageIdentity.Version) == AsVersion(expr2.Value);
                        case Operator.NotEqual: return AsVersion(package.PackageIdentity.Version) != AsVersion(expr2.Value);
                        case Operator.GreaterThan: return AsVersion(package.PackageIdentity.Version) > AsVersion(expr2.Value);
                        case Operator.LessThan: return AsVersion(package.PackageIdentity.Version) < AsVersion(expr2.Value);
                        case Operator.GreaterThanOrEqual: return AsVersion(package.PackageIdentity.Version) >= AsVersion(expr2.Value);
                        case Operator.LessThanOrEqual: return AsVersion(package.PackageIdentity.Version) <= AsVersion(expr2.Value);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            return true;
        }
Beispiel #8
0
 protected bool Equals(PackageItem other)
 {
     return string.Equals(PackageIdentity, other.PackageIdentity);
 }
Beispiel #9
0
        private bool MarkRelated(PackageItem[] installed = null, PackageItem[] updated = null, PackageItem[] removed = null, bool unmark = false)
        {
            if ((installed != null && installed.Any()) || (updated != null && updated.Any()) || (removed != null && removed.Any()))
            {
                if (Options.AskToConfirmChangesThatAlsoAffectOtherPackages)
                {
                    var canProceed = WindowManager.ShowDialog(new MarkAdditionalChangesViewModel(installed, updated, removed));

                    if (canProceed != true)
                        return false;
                }

                if (installed != null) foreach (var p in installed)
                    p.Mark = unmark ? PackageMark.Unmarked : PackageMark.MarkedForInstallation;

                if (updated != null) foreach (var p in updated)
                    p.Mark = unmark ? PackageMark.Unmarked : PackageMark.MarkedForInstallation;

                if (removed != null) foreach (var p in removed)
                    p.Mark = unmark ? PackageMark.Unmarked : PackageMark.MarkedForRemoval;
            }
            return true;
        }