コード例 #1
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidatorAttribute"/>.</para>
        /// </summary>
        /// <param name="lowerBound">The lower bound.</param>
        /// <param name="lowerUnit">The lower bound unit of time.</param>
        /// <param name="lowerBoundType">The indication of how to perform the lower bound check.</param>
        /// <param name="upperBound">The upper bound</param>
        /// <param name="upperUnit">The upper bound unit of time.</param>
        /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param>
        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;
        }
コード例 #2
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidator"/>.</para>
        /// </summary>
        /// <param name="negated">True if the validator must negate the result of the validation.</param>
        /// <param name="messageTemplate">The message template to use when logging results.</param>
        /// <param name="lowerBound">The lower bound.</param>
        /// <param name="lowerUnit">The lower bound unit of time.</param>
        /// <param name="lowerBoundType">The indication of how to perform the lower bound check.</param>
        /// <param name="upperBound">The upper bound</param>
        /// <param name="upperUnit">The upper bound unit of time.</param>
        /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param>
        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.lowerBoundType = lowerBoundType;
            this.upperBound     = upperBound;
            this.upperUnit      = upperUnit;
            this.upperBoundType = upperBoundType;

            BuildRangeChecker();    // force validation of parameters
        }