Exemplo n.º 1
0
        /**
         * 检测传入的元素类型
         *
         * @param listTpye
         * @param o
         */
        private void CheckObjectType(List <string> listTpye, Object o)
        {
            if (o == null)
            {
                throw new Exception("object is null");
            }

            if (o.GetType().IsArray)
            {
                Type elementType = o.GetType().GetElementType();
                listTpye.Add("list");
                CheckObjectType(listTpye, BasicClassTypeUtil.CreateObject(elementType));
            }
            else if (o is IList)
            {
                listTpye.Add("list");

                IList list = (IList)o;
                if (list.Count > 0)
                {
                    CheckObjectType(listTpye, list[0]);
                }
                else
                {
                    listTpye.Add("?");
                }
            }
            else if (o is IDictionary)
            {
                listTpye.Add("map");
                IDictionary map = (IDictionary)o;
                if (map.Count > 0)
                {
                    foreach (object key in map.Keys)
                    {
                        listTpye.Add(BasicClassTypeUtil.CS2UniType(key.GetType().ToString()));
                        CheckObjectType(listTpye, map[key]);
                        break;
                    }
                }
                else
                {
                    listTpye.Add("?");
                    listTpye.Add("?");
                    //throw new ArgumentException("map  can not is empty");
                }
            }
            else
            {
                listTpye.Add(BasicClassTypeUtil.CS2UniType(o.GetType().ToString()));
            }
        }
Exemplo n.º 2
0
 private Object GetCacheProxy <T>(string className)
 {
     return(BasicClassTypeUtil.CreateObject <T>());
 }