Esempio n. 1
0
        /// <summary>
        /// Obtains the value of the reference on a specific instance.
        /// </summary>
        /// <param name="instance">The instance to inspect.</param>
        /// <returns></returns>
        public object GetReferenceValue(object instance)
        {
            if (referenceAccessor != null)
            {
                return(referenceAccessor(instance));
            }

            return(AccessorUtil.GetPathValue(instance, propertyToCompare));
        }
Esempio n. 2
0
        /// <summary>
        /// Implementors should perform the actual validation upon
        /// the property value
        /// </summary>
        /// <param name="instance">The target type instance</param>
        /// <returns><c>true</c> if the field is OK</returns>
        public bool IsValid(object instance)
        {
            object value;

            if (propertyAccessor != null)
            {
                value = propertyAccessor(instance);
            }
            else
            {
                value = AccessorUtil.GetPropertyValue(instance, Property);
            }

            return(IsValid(instance, value));
        }
Esempio n. 3
0
 /// <summary>
 /// Gets the expression value accessor.
 /// </summary>
 /// <param name="targetType">The target type.</param>
 /// <param name="path">The expression path.</param>
 /// <returns>The expression accessor.</returns>
 public Accessor GetFieldOrPropertyAccessor(Type targetType, string path)
 {
     return(AccessorUtil.GetAccessor(targetType, path));
 }
Esempio n. 4
0
 /// <summary>
 /// Gets the property value accessor.
 /// </summary>
 /// <param name="property">The property.</param>
 /// <returns>The property value accessor.</returns>
 public Accessor GetPropertyAccessor(PropertyInfo property)
 {
     return(AccessorUtil.GetAccessor(property));
 }