コード例 #1
0
ファイル: VersionRequirements.cs プロジェクト: sjb8100/uplift
 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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #4
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);
 }
コード例 #5
0
ファイル: VersionRequirements.cs プロジェクト: sjb8100/uplift
 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);
 }
コード例 #6
0
            public void ResrictToNoRequirement()
            {
                NoRequirement noRequirement = new NoRequirement();

                Assert.AreSame(requirement.RestrictTo(noRequirement), requirement);
            }
コード例 #7
0
 public void RestrictToItself()
 {
     Assert.AreSame(requirement.RestrictTo(requirement), requirement);
 }