private PropertyValidationError ValidateSingleValue(ExchangeOperationContext context, object value, Type expectedType) { if (value == null) { return(new NullValueError(this, value)); } if (value is DateTime && expectedType.Equals(typeof(ExDateTime))) { expectedType = typeof(DateTime); } Type type = value.GetType(); if (!expectedType.Equals(type) && !expectedType.GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) { return(new TypeMismatchError(this, value)); } for (int i = 0; i < this.constraints.Count; i++) { PropertyValidationError propertyValidationError = this.constraints[i].Validate(context, value, this, null); if (propertyValidationError != null) { return(propertyValidationError); } } return(null); }
public override PropertyConstraintViolationError Validate(ExchangeOperationContext context, object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag) { ArgumentValidator.ThrowIfNull("propertyDefinition", propertyDefinition); if (context == null || !context.IsMoveUser) { return(this.Validate(value, propertyDefinition, propertyBag)); } NonMoveMailboxPropertyConstraint.Tracer.TraceDebug <PropertyDefinition>((long)this.GetHashCode(), "Skipping validation of property '{0}' during move mailbox stage", propertyDefinition); return(null); }
private void ValidateSetPropertyValue(ExchangeOperationContext context, object value) { if (value == null) { throw new ArgumentNullException(base.Name); } PropertyValidationError[] array = this.Validate(context, value); if (array.Length > 0) { PropertyValidationError propertyValidationError = array[0]; throw new PropertyValidationException(propertyValidationError.Description, propertyValidationError.PropertyDefinition, array); } }
public PropertyValidationError[] Validate(ExchangeOperationContext context, object value) { if ((this.PropertyFlags & PropertyFlags.Multivalued) == PropertyFlags.Multivalued) { return(this.ValidateMultiValue(context, value)); } PropertyValidationError propertyValidationError = this.ValidateSingleValue(context, value, base.Type); if (propertyValidationError != null) { return(new PropertyValidationError[] { propertyValidationError }); } return(StorePropertyDefinition.NoValidationError); }
private PropertyValidationError[] ValidateMultiValue(ExchangeOperationContext context, object value) { if (value == null) { return(new PropertyValidationError[] { new NullValueError(this, value) }); } IEnumerable enumerable = value as IEnumerable; if (enumerable == null) { return(new PropertyValidationError[] { new TypeMismatchError(this, value) }); } if (!value.GetType().Equals(base.Type)) { return(new PropertyValidationError[] { new TypeMismatchError(this, value) }); } int num = 0; List <PropertyValidationError> list = new List <PropertyValidationError>(); Type elementType = base.Type.GetElementType(); int num2 = 0; foreach (object value2 in enumerable) { num++; PropertyValidationError propertyValidationError = this.ValidateSingleValue(context, value2, elementType); if (propertyValidationError != null) { PropertyValidationError item = new InvalidMultivalueElementError(propertyValidationError, value, num2); list.Add(item); } num2++; } return(list.ToArray()); }
internal void Set(ExchangeOperationContext operationContext, PropertyBag.BasicPropertyStore propertyBag, object value) { this.ValidateSetPropertyValue(operationContext, value); this.InternalSetValue(propertyBag, value); }