/// <summary>
        /// Loads the values of an object's properties into a <see cref="IDictionary{String,Object}"/>.
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        /// <returns>If <paramref name="dataObject"/> implements <see cref="IDictionary{String,Object}"/>,
        /// the object is cast to <see cref="IDictionary{String,Object}"/> and returned.
        /// Otherwise the object returned is a <see cref="System.Collections.Hashtable"/> with all public non-static properties and their respective values
        /// as key-value pairs.
        /// </returns>
        public static IDictionary <string, object> Convert(object dataObject)
        {
            if (dataObject == null)
            {
                return(new Dictionary <string, object>());
            }

            return(dataObject as IDictionary <string, object> ??
                   GetObjectToDictionaryConverter(dataObject)(dataObject));
        }
Example #2
0
        public IDictionary <string, object> Convert(object dataObject)
        {
            if (dataObject == null)
            {
                return(_default);
            }

            if (dataObject is IDictionary <string, object> )
            {
                return((IDictionary <string, object>)dataObject);
            }

            return(GetObjectToDictionaryConverter(dataObject)(dataObject));
        }