コード例 #1
0
 	protected virtual void CopyProperties(Rule rule)
 	{
 		rule.UseErrorMessageProvider = UseErrorMessageProvider;
 		rule.ErrorMessage = ErrorMessage;
 		rule.RuleSet = RuleSet;
 		rule.Severity = Severity;
 	}
コード例 #2
0
        /// <remarks>
        /// null is an invalid value for both <paramref name="rule"/> and <paramref name="errorMessage"/>. 
        /// Due to performance concerns <see cref="ArgumentNullException"/> will no be thrown.
        /// So just don't pass in null or an empty string.
        /// </remarks>
        /// <param name="rule">The <see cref="Rule"/> that this <see cref="ValidationError"/> has been generated from.</param>
        /// <param name="errorMessage">The error message.</param>
		/// <param name="attemptedValue">The invalid member's value</param>
        /// <param name="infoDescriptor">The <see cref="InfoDescriptor"/> that this <see cref="ValidationError"/> has been generated from.</param>
        public ValidationError(Rule rule, string errorMessage, object attemptedValue, InfoDescriptor infoDescriptor)
        {
            //Dont guard these. the performance hit is not worth the minor help it gives developers. 
            Rule = rule;
            ErrorMessage = errorMessage;
			AttemptedValue = attemptedValue;
            InfoDescriptor = infoDescriptor;
        }
コード例 #3
0
		/// <inheritdoc />
        public override bool IsEquivalent(Rule rule)
        {
			var numberConversionRule = (NumberConversionRule)rule;
			return numberConversionRule.TypeCode == TypeCode &&
				numberConversionRule.NumberStyles == NumberStyles &&
				numberConversionRule.NumberFormatInfo == NumberFormatInfo;
        }
コード例 #4
0
		/// <inheritdoc />
        public override bool IsEquivalent(Rule rule)
        {
            var lengthCollectionRule = (LengthCollectionRule) rule;
            return lengthCollectionRule.ExcludeDuplicatesFromCount == ExcludeDuplicatesFromCount && lengthCollectionRule.Comparer == Comparer;
        }
コード例 #5
0
		/// <inheritdoc />
        public override bool IsEquivalent(Rule rule)
        {
            var lengthRule = (LengthRule) rule;
            return lengthRule.Maximum == Maximum && lengthRule.Minimum == Minimum;
        }
コード例 #6
0
		/// <inheritdoc />
        public override bool IsEquivalent(Rule rule)
        {
            var customRule = (CustomRule)rule;
            return uniqueHash == customRule.uniqueHash;
        }
コード例 #7
0
		/// <inheritdoc />
        public override bool IsEquivalent(Rule rule)
        {
            return (base.IsEquivalent(rule) && ((LengthStringRule) rule).TrimWhiteSpace == TrimWhiteSpace);
        }
コード例 #8
0
		/// <inheritdoc />
        public override bool IsEquivalent(Rule rule)
        {
			var enumConversionRule = (EnumConversionRule)rule;
        	return enumConversionRule.EnumType == EnumType;
        }
		/// <inheritdoc />
        public override bool IsEquivalent(Rule rule)
        {
			var dateTimeConversionRule = (DateTimeConversionRule)rule;
			return dateTimeConversionRule.Format == Format &&
				dateTimeConversionRule.DateTimeStyles == DateTimeStyles &&
				dateTimeConversionRule.DateTimeFormatInfo == DateTimeFormatInfo;
        }
コード例 #10
0
		/// <inheritdoc />
        public override bool IsEquivalent(Rule rule)
        {
            var regexRule = (RegexRule) rule;
            return regexRule.RegexOptions == RegexOptions && regexRule.ValidationExpression == ValidationExpression;
        }
コード例 #11
0
		/// <inheritdoc />
        public override bool IsEquivalent(Rule rule)
        {
            return true;
        }
コード例 #12
0
 /// <summary>
 /// Checks if the current <see cref="Rule"/> is equivalent to another <see cref="Rule"/>.
 /// </summary>
 /// <remarks>
 /// Called for each <see cref="Rule"/> in <see cref="RuleCollection"/> when a new <see cref="Rule"/> is added. This method is only called when both the existing <see cref="Rule"/> and the <see cref="Rule"/> being are of the same <see cref="Type"/> and have the same <see cref="RuleSet"/>. So it is safe to directly cast <paramref name="rule"/> to the current type. All properties in <paramref name="rule"/> should be compared to the propeties of the current <see cref="Rule"/>.
 /// </remarks>
 /// <param name="rule">The <see cref="Rule"/> to check for equivalence.</param>
 /// <returns><see langword="true"/> if <paramref name="rule"/> is equivalent to the current <see cref="Rule"/>; otherwise <see langword="false"/>.</returns>
 public abstract bool IsEquivalent(Rule rule);
コード例 #13
0
		/// <inheritdoc />
        public override bool IsEquivalent(Rule rule)
        {
            var comparePropertyRule = (ComparePropertyRule) rule;
            return ((comparePropertyRule.PropertyToCompare == PropertyToCompare) && (CompareOperator == comparePropertyRule.CompareOperator));
        }