Hishop.Components.Validation/Validators/RangeChecker!1.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
namespace Hishop.Components.Validation.Validators
{
using Hishop.Components.Validation.Properties;
using System;
internal class RangeChecker<T> where T: IComparable
{
private T lowerBound;
private RangeBoundaryType lowerBoundType;
private T upperBound;
private RangeBoundaryType upperBoundType;
public RangeChecker(T lowerBound, RangeBoundaryType lowerBoundType, T upperBound, RangeBoundaryType upperBoundType)
{
if ((upperBound == null) && (upperBoundType != RangeBoundaryType.Ignore))
{
throw new ArgumentException(Resources.ExceptionUpperBoundNull);
}
if ((lowerBound == null) && (lowerBoundType != RangeBoundaryType.Ignore))
{
throw new ArgumentException(Resources.ExceptionLowerBoundNull);
}
if (((lowerBoundType != RangeBoundaryType.Ignore) && (upperBoundType != RangeBoundaryType.Ignore)) && (upperBound.CompareTo(lowerBound) < 0))
{
throw new ArgumentException(Resources.ExceptionUpperBoundLowerThanLowerBound);
}
this.lowerBound = lowerBound;
this.lowerBoundType = lowerBoundType;
this.upperBound = upperBound;
this.upperBoundType = upperBoundType;
}
public bool IsInRange(T target)
{
if (this.lowerBoundType > RangeBoundaryType.Ignore)
{
int num = this.lowerBound.CompareTo(target);
if (num > 0)
{
return false;
}
if ((this.lowerBoundType == RangeBoundaryType.Exclusive) && (num == 0))
{
return false;
}
}
if (this.upperBoundType > RangeBoundaryType.Ignore)
{
int num2 = this.upperBound.CompareTo(target);
if (num2 < 0)
{
return false;
}
if ((this.upperBoundType == RangeBoundaryType.Exclusive) && (num2 == 0))
{
return false;
}
}
return true;
}
后面还有 35 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
