internal static void ValidateProperties(ValidationContext context, IValidatable validatable, IValidatablePropertyBag propertyBag, IList <StoreObjectValidationError> validationErrors) { foreach (StoreObjectConstraint storeObjectConstraint in validatable.Schema.Constraints) { bool flag = validatable.ValidateAllProperties; if (!flag) { foreach (PropertyDefinition propertyDefinition in storeObjectConstraint.RelevantProperties) { if (propertyBag.IsPropertyDirty(propertyDefinition)) { flag = true; break; } } } if (flag) { StoreObjectValidationError storeObjectValidationError = storeObjectConstraint.Validate(context, propertyBag); if (storeObjectValidationError != null) { validationErrors.Add(storeObjectValidationError); } } } }
internal static StoreObjectValidationError[] CreateStoreObjectValiationErrorArray(IValidatable validatable, ValidationContext context) { IList <StoreObjectValidationError> list = new List <StoreObjectValidationError>(); validatable.Validate(context, list); StoreObjectValidationError[] array; if (list.Count > 0) { array = new StoreObjectValidationError[list.Count]; list.CopyTo(array, 0); } else { array = Validation.EmptyValidationErrorArray; } return(array); }
internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag) { StoreObjectValidationError storeObjectValidationError = null; foreach (StoreObjectConstraint storeObjectConstraint in base.Constraints) { StoreObjectValidationError storeObjectValidationError2 = storeObjectConstraint.Validate(context, validatablePropertyBag); if (storeObjectValidationError2 == null) { return(null); } if (storeObjectValidationError == null) { storeObjectValidationError = storeObjectValidationError2; } } return(new StoreObjectValidationError(context, storeObjectValidationError.PropertyDefinition, storeObjectValidationError.InvalidData, this)); }
private void ValidateAndFillInDefaults() { foreach (PropertyDefinition propertyDefinition in CategorySchema.Instance.AllProperties) { XmlAttributePropertyDefinition xmlAttributePropertyDefinition = propertyDefinition as XmlAttributePropertyDefinition; if (xmlAttributePropertyDefinition != null) { object obj = this.propertyBag.TryGetProperty(xmlAttributePropertyDefinition); PropertyValidationError[] array = null; if (PropertyError.IsPropertyNotFound(obj) || (array = xmlAttributePropertyDefinition.Validate(null, obj)).Length > 0) { if (xmlAttributePropertyDefinition.HasDefaultValue) { this.propertyBag[xmlAttributePropertyDefinition] = xmlAttributePropertyDefinition.DefaultValue; } else if (array != null && array.Length > 0) { throw new PropertyValidationException(array[0].Description, xmlAttributePropertyDefinition, array); } } } } List <StoreObjectValidationError> list = new List <StoreObjectValidationError>(); ValidationContext context = new ValidationContext(null); foreach (StoreObjectConstraint storeObjectConstraint in CategorySchema.Instance.Constraints) { StoreObjectValidationError storeObjectValidationError = storeObjectConstraint.Validate(context, this.propertyBag); if (storeObjectValidationError != null) { list.Add(storeObjectValidationError); } } if (list.Count > 0) { throw new ObjectValidationException(list[0].Description, list.ToArray()); } }