Example #1
0
 public IVersionRequirement RestrictTo(IVersionRequirement other)
 {
     if (other is NoRequirement || other is MinimalVersionRequirement || other is LoseVersionRequirement)
     {
         return(other.RestrictTo(this));
     }
     else if (other is BoundedVersionRequirement)
     {
         if (IsMetBy((other as BoundedVersionRequirement).lowerBound))
         {
             return(other);
         }
         if ((other as BoundedVersionRequirement).IsMetBy(lowerBound))
         {
             return(this);
         }
     }
     else if (other is ExactVersionRequirement)
     {
         if (IsMetBy((other as ExactVersionRequirement).expected))
         {
             return(other);
         }
     }
     throw new IncompatibleRequirementException(this, other);
 }
Example #2
0
 public IVersionRequirement RestrictTo(IVersionRequirement other)
 {
     if (other is NoRequirement)
     {
         return(other.RestrictTo(this));
     }
     else if (other is MinimalVersionRequirement)
     {
         return(minimal >= (other as MinimalVersionRequirement).minimal ? this : other);
     }
     else if (other is LoseVersionRequirement)
     {
         if (minimal <= (other as LoseVersionRequirement).stub)
         {
             return(other);
         }
     }
     else if (other is BoundedVersionRequirement)
     {
         if (minimal <= (other as BoundedVersionRequirement).lowerBound)
         {
             return(other);
         }
     }
     else if (other is ExactVersionRequirement)
     {
         if (minimal <= (other as ExactVersionRequirement).expected)
         {
             return(other);
         }
     }
     throw new IncompatibleRequirementException(this, other);
 }
Example #3
0
 public IVersionRequirement RestrictTo(IVersionRequirement other)
 {
     if (other is NoRequirement)
     {
         return(other.RestrictTo(this));
     }
     else if (other is MinimalVersionRequirement)
     {
         return(minimal >= (other as MinimalVersionRequirement).minimal ? this : other);
     }
     else if (other is RangeVersionRequirement)
     {
         if (minimal <= (other as RangeVersionRequirement).lower)
         {
             return(other);
         }
         if (other.IsMetBy(minimal))
         {
             return(new RangeVersionRequirement(
                        minimal,
                        (other as RangeVersionRequirement).upper));
         }
     }
     else if (other is ExactVersionRequirement)
     {
         if (minimal <= (other as ExactVersionRequirement).expected)
         {
             return(other);
         }
     }
     throw new IncompatibleRequirementException(this, other);
 }
Example #4
0
 public override IVersionRequirement RestrictTo(IVersionRequirement other)
 {
     if (other is LoseVersionRequirement)
     {
         return((other as LoseVersionRequirement).RestrictTo(this as BoundedVersionRequirement));
     }
     return(base.RestrictTo(other));
 }
Example #5
0
            public void ParseLoseRequirement()
            {
                IVersionRequirement parsed = VersionParser.ParseRequirement("1.2");

                Assert.IsTrue(parsed is LoseVersionRequirement);
                Assert.AreEqual((parsed as LoseVersionRequirement).stub, new Version {
                    Major = 1, Minor = 2
                });
            }
Example #6
0
            public void ParseMinimalRequirement()
            {
                IVersionRequirement parsed = VersionParser.ParseRequirement("1.2+");

                Assert.IsTrue(parsed is MinimalVersionRequirement);
                Assert.AreEqual((parsed as MinimalVersionRequirement).minimal, new Version {
                    Major = 1, Minor = 2
                });
            }
Example #7
0
            public void ParseBoundedRequirement()
            {
                IVersionRequirement parsed = VersionParser.ParseRequirement("1.2.*");

                Assert.IsTrue(parsed is BoundedVersionRequirement);
                Assert.AreEqual((parsed as BoundedVersionRequirement).lower, new Version {
                    Major = 1, Minor = 2
                });
            }
Example #8
0
            public void ParseExactRequirement()
            {
                IVersionRequirement parsed = VersionParser.ParseRequirement("1.2.3!");

                Assert.IsTrue(parsed is ExactVersionRequirement);
                Assert.AreEqual((parsed as ExactVersionRequirement).expected, new Version {
                    Major = 1, Minor = 2, Patch = 3
                });
            }
Example #9
0
 public override IVersionRequirement RestrictTo(IVersionRequirement other)
 {
     if (other is BoundedVersionRequirement)
     {
         if (IsMetBy((other as BoundedVersionRequirement).lower))
         {
             return(other);
         }
     }
     return(base.RestrictTo(other));
 }
Example #10
0
            public void ParseRangeRequirement()
            {
                IVersionRequirement parsed = VersionParser.ParseRequirement("1.2,3.4");

                Assert.IsTrue(parsed is RangeVersionRequirement);
                Assert.AreEqual((parsed as RangeVersionRequirement).lower, new Version {
                    Major = 1, Minor = 2
                });
                Assert.AreEqual((parsed as RangeVersionRequirement).upper, new Version {
                    Major = 3, Minor = 4
                });
            }
Example #11
0
        public DependencyNode(string name, string version, string repository, SkipInstallSpec[] skips, OverrideDestinationSpec[] overrides, List <DependencyNode> dependencies)
        {
            this.name         = name;
            this.requirement  = VersionParser.ParseRequirement(version);
            this.repository   = repository;
            this.dependencies = dependencies;
            this.skips        = skips;
            this.overrides    = overrides;

            index   = -1;
            lowlink = -1;
        }
Example #12
0
 public virtual IVersionRequirement RestrictTo(IVersionRequirement other)
 {
     if (other is NoRequirement || other is MinimalVersionRequirement)
     {
         return(other.RestrictTo(this));
     }
     else if (other is RangeVersionRequirement)
     {
         var otherRange = other as RangeVersionRequirement;
         if (lower == otherRange.lower && upper == otherRange.upper)
         {
             return(this);
         }
         // self include other?
         if (IsMetBy(otherRange.lower) && IsMetBy(otherRange.upper))
         {
             return(other);
         }
         // other include self?
         if (other.IsMetBy(lower) && other.IsMetBy(upper))
         {
             return(this);
         }
         // They are overlapping or not intersecting
         // overlap top?
         if (IsMetBy(otherRange.lower) && other.IsMetBy(upper))
         {
             return(new RangeVersionRequirement(
                        otherRange.lower,
                        this.upper
                        ));
         }
         // overlap bottom?
         if (IsMetBy(otherRange.upper) && other.IsMetBy(lower))
         {
             return(new RangeVersionRequirement(
                        this.lower,
                        otherRange.upper
                        ));
         }
     }
     else if (other is ExactVersionRequirement)
     {
         if (IsMetBy((other as ExactVersionRequirement).expected))
         {
             return(other);
         }
     }
     throw new IncompatibleRequirementException(this, other);
 }
Example #13
0
 public IVersionRequirement RestrictTo(IVersionRequirement other)
 {
     if (other is ExactVersionRequirement)
     {
         if (IsMetBy((other as ExactVersionRequirement).expected))
         {
             return(this);
         }
     }
     else
     {
         return(other.RestrictTo(this));
     }
     throw new IncompatibleRequirementException(this, other);
 }
Example #14
0
 public static bool IsMetBy(this IVersionRequirement requirement, string version)
 {
     return(requirement.IsMetBy(VersionParser.ParseIncompleteVersion(version)));
 }
Example #15
0
 protected void Given()
 {
     requirement = new NoRequirement();
 }
Example #16
0
 protected void Given()
 {
     // 1.0+
     requirement = new MinimalVersionRequirement("1.0");
 }
Example #17
0
 protected void Given()
 {
     // 1.0
     requirement = new LoseVersionRequirement("1.0");
 }
Example #18
0
 public IncompatibleRequirementException(IVersionRequirement a, IVersionRequirement b)
     : this(string.Format("Requirements {0} and {1} are not compatible", a.ToString(), b.ToString()))
 {
 }
Example #19
0
 public IVersionRequirement RestrictTo(IVersionRequirement other)
 {
     return(other);
 }
Example #20
0
 protected void Given()
 {
     // 1.5,3.5
     requirement = new RangeVersionRequirement("1.5", "3.5");
 }
Example #21
0
 protected void Given()
 {
     // 1.0!
     requirement = new ExactVersionRequirement("1.0");
 }
Example #22
0
 protected void Given()
 {
     // 1.0.*
     requirement = new BoundedVersionRequirement("1.0");
 }