Ejemplo n.º 1
0
        /// <summary>
        /// Checks needed conditions to perform property update.
        /// </summary>
        /// <param name="propVal"></param>
        /// <param name="value"></param>
        internal void EnsurePropertySet(RadPropertyValue propVal, object value)
        {
            //1. It should not be marked as "Read-only"
            if (propVal.Metadata.ReadOnly)
            {
                throw new ArgumentException("Attemt to modify the value of a read-only property");
            }

            //2. Type of the specified value should match property type
            if (value != null && value != RadProperty.UnsetValue)
            {
                if (!RadProperty.IsValidType(value, propVal.Property.PropertyType))
                {
                    throw new ArgumentException("New value does not match declared property type.");
                }
            }

            //3. Is value valid - use metadata's defined callback
            if (propVal.Property.ValidateValueCallback != null)
            {
                if (!propVal.Property.ValidateValueCallback(value, this))
                {
                    throw new ArgumentException("Specified value " + value.ToString() + " is not valid for property " + propVal.Property.Name);
                }
            }
        }
Ejemplo n.º 2
0
 public bool IsValidValue(object value, RadObject instance)
 {
     if (!RadProperty.IsValidType(value, this.PropertyType))
     {
         return(false);
     }
     if (this.ValidateValueCallback != null)
     {
         return(this.ValidateValueCallback(value, instance));
     }
     return(true);
 }
Ejemplo n.º 3
0
 internal void EnsurePropertySet(RadPropertyValue propVal, object value)
 {
     if (propVal.Metadata.ReadOnly)
     {
         throw new ArgumentException("Attemt to modify the value of a read-only property");
     }
     if (value != null && value != RadProperty.UnsetValue && !RadProperty.IsValidType(value, propVal.Property.PropertyType))
     {
         throw new ArgumentException("New value does not match declared property type.");
     }
     if (propVal.Property.ValidateValueCallback != null && !propVal.Property.ValidateValueCallback(value, this))
     {
         throw new ArgumentException("Specified value " + value.ToString() + " is not valid for property " + propVal.Property.Name);
     }
 }
Ejemplo n.º 4
0
 public bool IsValidType(object value)
 {
     return(RadProperty.IsValidType(value, this.PropertyType));
 }