Hishop.Components.Validation/Validators/RelativeDateTimeValidatorAttribute.cs
(完整代码) 2KBnamespace Hishop.Components.Validation.Validators
{
using Hishop.Components.Validation;
using System;
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
public sealed class RelativeDateTimeValidatorAttribute : ValueValidatorAttribute
{
private int lowerBound;
private RangeBoundaryType lowerBoundType;
private DateTimeUnit lowerUnit;
private int upperBound;
private RangeBoundaryType upperBoundType;
private DateTimeUnit upperUnit;
public RelativeDateTimeValidatorAttribute(int upperBound, DateTimeUnit upperUnit) : this(0, DateTimeUnit.None, RangeBoundaryType.Ignore, upperBound, upperUnit, RangeBoundaryType.Inclusive)
{
}
public RelativeDateTimeValidatorAttribute(int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType) : this(0, DateTimeUnit.None, RangeBoundaryType.Ignore, upperBound, upperUnit, upperBoundType)
{
}
public RelativeDateTimeValidatorAttribute(int lowerBound, DateTimeUnit lowerUnit, int upperBound, DateTimeUnit upperUnit) : this(lowerBound, lowerUnit, RangeBoundaryType.Inclusive, upperBound, upperUnit, RangeBoundaryType.Inclusive)
{
}
public RelativeDateTimeValidatorAttribute(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType)
{
ValidatorArgumentsValidatorHelper.ValidateRelativeDatimeValidator(lowerBound, lowerUnit, lowerBoundType, upperBound, upperUnit, upperBoundType);
this.lowerBound = lowerBound;
this.lowerUnit = lowerUnit;
this.lowerBoundType = lowerBoundType;
this.upperBound = upperBound;
this.upperUnit = upperUnit;
this.upperBoundType = upperBoundType;
}
protected override Validator DoCreateValidator(Type targetType)
{
return new RelativeDateTimeValidator(this.lowerBound, this.lowerUnit, this.lowerBoundType, this.upperBound, this.upperUnit, this.upperBoundType, base.Negated);
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
