예제 #1
0
 /// <summary>
 /// 根据类型获取成员信息集合
 /// </summary>
 /// <param name="type">类型</param>
 /// <returns>成员信息集合</returns>
 private static memberInfo[] getMembers(Type type)
 {
     memberInfo[] members;
     if (!memberCache.TryGetValue(type, out members))
     {
         memberIndexGroup group = memberIndexGroup.Get(type);
         memberCache[type] = members =
             array.concat(group.PublicFields.getArray(value => new memberInfo(value)),
                          group.NonPublicFields.getArray(value => new memberInfo(value)),
                          group.PublicProperties.getArray(value => new memberInfo(value)),
                          group.NonPublicProperties.getArray(value => new memberInfo(value)));
     }
     return(members);
 }
예제 #2
0
        /// <summary>
        /// 根据类型获取成员索引分组
        /// </summary>
        /// <param name="type">对象类型</param>
        /// <returns>成员索引分组</returns>
        private static memberIndexGroup getStatic(Type type)
        {
            memberIndexGroup value;

            Monitor.Enter(staticCacheLock);
            try
            {
                if (!staticCache.TryGetValue(type, out value))
                {
                    staticCache.Add(type, value = new memberIndexGroup(type, true));
                }
            }
            finally { Monitor.Exit(staticCacheLock); }
            return(value);
        }
예제 #3
0
        /// <summary>
        /// 根据类型获取成员索引分组
        /// </summary>
        /// <param name="type">对象类型</param>
        /// <returns>成员索引分组</returns>
        public static memberIndexGroup Get(Type type)
        {
            memberIndexGroup value;

            Monitor.Enter(cacheLock);
            try
            {
                if (!cache.TryGetValue(type, out value))
                {
                    cache.Add(type, value = new memberIndexGroup(type, false));
                }
            }
            finally { Monitor.Exit(cacheLock); }
            return(value);
        }