示例#1
0
 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;
 }
        public RelativeDateTimeValidator(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType, string messageTemplate, bool negated) : base(messageTemplate, null, negated)
        {
            ValidatorArgumentsValidatorHelper.ValidateRelativeDatimeValidator(lowerBound, lowerUnit, lowerBoundType, upperBound, upperUnit, upperBoundType);
            this.lowerBound = lowerBound;
            this.lowerUnit  = lowerUnit;
            this.upperBound = upperBound;
            this.upperUnit  = upperUnit;
            this.generator  = new RelativeDateTimeGenerator();
            DateTime now   = DateTime.Now;
            DateTime time2 = this.generator.GenerateBoundDateTime(lowerBound, lowerUnit, now);
            DateTime time3 = this.generator.GenerateBoundDateTime(upperBound, upperUnit, now);

            this.rangeChecker = new RangeChecker <DateTime>(time2, lowerBoundType, time3, upperBoundType);
        }