Beispiel #1
0
        private static void AddEnumerableObjectDetail(IEnumerable collection, List <KeyValuePair <String, String> > list, String prefix)
        {
            Type   type         = collection.GetType();
            Int32  count        = 0;
            String prefixFormat = String.Format("{0}Item[{{0}}].", prefix);


            foreach (Object obj in collection)
            {
                if (count < 100)
                {
                    CacheManager.AddObjectDetail(obj, list, String.Format(prefixFormat, count.ToString()));
                }

                count++;
            }

            if (count > 100)
            {
                list.Add(new KeyValuePair <String, String>("...", "There are too many items in this object."));
            }

            list.Add(new KeyValuePair <String, String>("Type", type.ToString()));
            list.Add(new KeyValuePair <String, String>("Count", count.ToString()));
        }
Beispiel #2
0
        /// <summary>
        /// 获取指定缓存变量(可为null)
        /// </summary>
        /// <param name="key">缓存变量名</param>
        /// <returns>指定缓存变量(可为null)</returns>
        public static List <KeyValuePair <String, String> > GetDetail(String key)
        {
            if (String.IsNullOrEmpty(key))
            {
                return(null);
            }

            Object obj = CacheManager.GetObject(key);

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

            List <KeyValuePair <String, String> > list = new List <KeyValuePair <String, String> >();

            CacheManager.AddObjectDetail(obj, list, "");

            return(list);
        }