Exemplo n.º 1
0
        /// <summary>
        ///  对象转实体
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public static Dictionary <string, object> ToDictionary(this object o)
        {
            Type t = o.GetType();
            Dictionary <string, object> dic = new Dictionary <string, object>();

            if (!t.ExistsCacheProperty())
            {
                t.AddProperty();
            }

            List <PropertyInfo> p = _MetadataStack.PropertyList[t.FullName];

            for (int i = 0; i < p.Count; i++)
            {
                //_metadatastack
                //if (p[i].Name.ToUpper().IndexOf("ITEM") >= 0) continue; //剔除掉索引器
                //_metadatastack.GetFastInvokeHandler(t.FullName + p[i].Name + "get").Invoke(o, null);
                //dic[p[i].Name] = p[i].GetValue(o, null);
                dic[p[i].Name] = _metadatastack.GetFastInvokeHandler(t.FullName + p[i].Name + "get").Invoke(o, null);
            }

            return(dic);
        }