void CheckValueBoundaries(CfgAttribute itemAttributes, string name, object value) { if (!itemAttributes.MinValueSet && !itemAttributes.MaxValueSet) { return; } var comparable = value as IComparable; if (comparable == null) { Events.ValueIsNotComparable(name, value); } else { if (itemAttributes.MinValueSet) { if (comparable.CompareTo(itemAttributes.minValue) < 0) { Events.ValueTooSmall(name, value, itemAttributes.minValue); } } if (!itemAttributes.MaxValueSet) { return; } if (comparable.CompareTo(itemAttributes.maxValue) > 0) { Events.ValueTooBig(name, value, itemAttributes.maxValue); } } }
public CfgMetadata(PropertyInfo propertyInfo, CfgAttribute attribute) { PropertyInfo = propertyInfo; Attribute = attribute; if (!string.IsNullOrEmpty(attribute.domain)) { var comparer = attribute.ignoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal; _domainSet = new HashSet <string>(attribute.domain.Split(new[] { attribute.delimiter }, StringSplitOptions.None).Distinct(), comparer); } }
void CheckValueLength(CfgAttribute itemAttributes, string name, string value) { if (itemAttributes.MinLengthSet) { if (value.Length < itemAttributes.minLength) { Events.ValueTooShort(name, value, itemAttributes.minLength); } } if (!itemAttributes.MaxLengthSet) { return; } if (value.Length > itemAttributes.maxLength) { Events.ValueTooLong(name, value, itemAttributes.maxLength); } }
public CfgMetadata(PropertyInfo propertyInfo, CfgAttribute attribute) { PropertyInfo = propertyInfo; Attribute = attribute; if (!string.IsNullOrEmpty(attribute.domain)) { if (attribute.domainDelimiter == default(char)) { attribute.domainDelimiter = DefaultDelimiter; } var comparer = attribute.ignoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal; _domainSet = new HashSet<string>(attribute.domain.Split(new[] { attribute.domainDelimiter }, StringSplitOptions.None).Distinct(), comparer); } if (string.IsNullOrEmpty(attribute.validators)) return; if (attribute.validatorDelimiter == default(char)) { attribute.validatorDelimiter = DefaultDelimiter; } _validatorSet = new HashSet<string>( attribute.validators.Split(new[] { attribute.validatorDelimiter }, StringSplitOptions.None).Distinct(), attribute.ignoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal); }
void CheckValueBoundaries(CfgAttribute itemAttributes, string name, object value) { if (!itemAttributes.MinValueSet && !itemAttributes.MaxValueSet) return; var comparable = value as IComparable; if (comparable == null) { Events.ValueIsNotComparable(name, value); } else { if (itemAttributes.MinValueSet) { if (comparable.CompareTo(itemAttributes.minValue) < 0) { Events.ValueTooSmall(name, value, itemAttributes.minValue); } } if (!itemAttributes.MaxValueSet) return; if (comparable.CompareTo(itemAttributes.maxValue) > 0) { Events.ValueTooBig(name, value, itemAttributes.maxValue); } } }
void CheckValueLength(CfgAttribute itemAttributes, string name, string value) { if (itemAttributes.MinLengthSet) { if (value.Length < itemAttributes.minLength) { Events.ValueTooShort(name, value, itemAttributes.minLength); } } if (!itemAttributes.MaxLengthSet) return; if (value.Length > itemAttributes.maxLength) { Events.ValueTooLong(name, value, itemAttributes.maxLength); } }