Ejemplo n.º 1
0
        /// <summary>
        ///     Gets the processed value of this member in the specified object
        /// </summary>
        /// <param name="obj">The object whose value corresponding to this instance, must be retreived.</param>
        /// <returns>the processed value of this member in the specified object</returns>
        public object GetValue(object obj)
        {
            var elementValue = GetOriginalValue(obj, null);

            if (elementValue == null)
            {
                return(null);
            }

            if (_memberTypeWrapper.IsEnum)
            {
                return(_memberTypeWrapper.EnumWrapper.GetAlias(elementValue));
            }

            // trying to build the element value
            if (HasFormat && !IsTreatedAsCollection)
            {
                // do the formatting. If formatting succeeds the type of
                // the elementValue will become 'System.String'
                elementValue = ReflectionUtils.TryFormatObject(elementValue, Format);
            }

            return(elementValue);
        }