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); }
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); }
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 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 ExactVersionRequirement) { if (IsMetBy((other as ExactVersionRequirement).expected)) { return(this); } } else { return(other.RestrictTo(this)); } throw new IncompatibleRequirementException(this, other); }
public void ResrictToNoRequirement() { NoRequirement noRequirement = new NoRequirement(); Assert.AreSame(requirement.RestrictTo(noRequirement), requirement); }
public void RestrictToItself() { Assert.AreSame(requirement.RestrictTo(requirement), requirement); }