Ejemplo n.º 1
0
 private void ValidateCalculatedProperty(ProviderPropertyDefinition propertyDefinition, PropertyBag propertyBag, List <ValidationError> errors, bool useOnlyReadConstraints, bool onlyCacheValue)
 {
     try
     {
         object value = propertyBag[propertyDefinition];
         if (!onlyCacheValue)
         {
             IList <ValidationError> list = propertyDefinition.ValidateProperty(value, propertyBag, useOnlyReadConstraints);
             if (list.Count > 0)
             {
                 foreach (ValidationError item in list)
                 {
                     if (!errors.Contains(item))
                     {
                         errors.Add(item);
                     }
                 }
             }
         }
     }
     catch (DataValidationException ex)
     {
         ExTraceGlobals.ValidationTracer.TraceWarning <ProviderPropertyDefinition, DataValidationException>(0L, "Calculated property {0} threw an exception {1}.", propertyDefinition, ex);
         if (useOnlyReadConstraints && !onlyCacheValue)
         {
             errors.Add(ex.Error);
         }
     }
 }
Ejemplo n.º 2
0
        private void RunFullPropertyValidation(List <ValidationError> errors)
        {
            IEnumerable <PropertyDefinition> enumerable = (this.ObjectSchema == null) ? ((IEnumerable <PropertyDefinition>) this.propertyBag.Keys) : this.ObjectSchema.AllProperties;

            foreach (PropertyDefinition propertyDefinition in enumerable)
            {
                ProviderPropertyDefinition providerPropertyDefinition = (ProviderPropertyDefinition)propertyDefinition;
                if (!this.SkipFullPropertyValidation(providerPropertyDefinition))
                {
                    if (providerPropertyDefinition.IsCalculated)
                    {
                        this.ValidateCalculatedProperty(providerPropertyDefinition, this.propertyBag, errors, false, false);
                    }
                    else
                    {
                        object value = null;
                        this.propertyBag.TryGetField(providerPropertyDefinition, ref value);
                        IList <ValidationError> list = providerPropertyDefinition.ValidateProperty(value, this.propertyBag, false);
                        if (list.Count > 0)
                        {
                            foreach (ValidationError item in list)
                            {
                                if (!errors.Contains(item))
                                {
                                    errors.Add(item);
                                }
                            }
                        }
                    }
                }
            }
        }