예제 #1
0
        /// <summary>
        /// Return a yped value from an ExpandoObject
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static T Get <T>(this ExpandoObject obj, string name)
        {
            if (obj == null)
            {
                return(default(T));
            }
            var    dict = (IDictionary <string, object>)obj;
            object val;

            if (dict.TryGetValue(name, out val))
            {
                return(Objects.Convert <T>(val));
            }
            else
            {
                return(default(T));
            }
        }