Esempio n. 1
0
        /// <summary>Gets the value of the specified property on the specified object.</summary>
        /// <typeparam name="T">The type of the property value.</typeparam>
        /// <param name="propertyName">The name of the property to get the value for.</param>
        /// <param name="value">The object to get value from.</param>
        /// <param name="propertyValue">The value of the property if it exists; otherwise, <c>default(T)</c>.</param>
        /// <returns><c>true</c> if the property value of the specified type could be retrieved; otherwise, <c>false</c>.</returns>
        public virtual bool TryGetPropertyValue <T>(string propertyName, object value, out T propertyValue)
        {
            propertyValue = default(T);

            object uncastPropertyValue;

            if (!this.TryGetPropertyValue(propertyName, value, out uncastPropertyValue))
            {
                return(false);
            }

            return(FilterUtilities.TryCastItem <T>(uncastPropertyValue, out propertyValue));
        }
Esempio n. 2
0
        /// <summary>
        /// Determines if item matches a derived classes criteria.
        /// </summary>
        /// <param name="item">
        /// The item to match evaluate.
        /// </param>
        /// <returns>
        /// Returns true if the item matches, false otherwise.
        /// </returns>
        public override bool Evaluate(object item)
        {
            if (item == null)
            {
                return(this.DefaultNullValueEvaluation);
            }

            if (!this.IsValid)
            {
                return(false);
            }

            T castItem;

            if (!FilterUtilities.TryCastItem <T>(item, out castItem))
            {
                return(false);
            }

            return(this.Evaluate(castItem));
        }