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); }
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); }
public void IsMetBy() { Assert.IsFalse(requirement.IsMetBy("0.0.0")); Assert.IsFalse(requirement.IsMetBy("0.9.9")); Assert.IsTrue(requirement.IsMetBy("1.0")); Assert.IsTrue(requirement.IsMetBy("1.0.0")); Assert.IsTrue(requirement.IsMetBy("1.0.1")); Assert.IsTrue(requirement.IsMetBy("2.0.0")); Assert.IsTrue(requirement.IsMetBy("2")); }
public static bool IsMetBy(this IVersionRequirement requirement, string version) { return(requirement.IsMetBy(VersionParser.ParseIncompleteVersion(version))); }
public void IsMetBy() { Assert.IsTrue(requirement.IsMetBy("0.0.0")); Assert.IsTrue(requirement.IsMetBy("1.0.0")); Assert.IsTrue(requirement.IsMetBy("2.0.0")); }
public void IsMetBy() { Assert.IsFalse(requirement.IsMetBy("0.0.0")); Assert.IsFalse(requirement.IsMetBy("1.4.9")); Assert.IsTrue(requirement.IsMetBy("1.5")); Assert.IsTrue(requirement.IsMetBy("1.5.1")); Assert.IsTrue(requirement.IsMetBy("1.6")); Assert.IsTrue(requirement.IsMetBy("1.6.1")); Assert.IsTrue(requirement.IsMetBy("2")); Assert.IsTrue(requirement.IsMetBy("2.9")); Assert.IsTrue(requirement.IsMetBy("2.9.9")); Assert.IsFalse(requirement.IsMetBy("3.5")); Assert.IsFalse(requirement.IsMetBy("3.5.0")); }