예제 #1
0
            public static RuntimeInfo Create(Type type, Dictionary <Type, RuntimeInfo> tempCache)
            {
                if (type == null)
                {
                    return(null);
                }

                if ((type.IsValueType && !type.IsGenericType) || type == typeof(string))
                {
                    tempCache[type] = null;
                    return(null);
                }

                RuntimeInfo existing = null;

                if (InternalCache.TryGet(type, out existing))
                {
                    return(existing);
                }

                if (tempCache.TryGetValue(type, out existing))
                {
                    return(existing);
                }

                RuntimeInfo runtimeInfo = null;

                tempCache[type] = runtimeInfo = new RuntimeInfo()
                {
                    _type       = type,
                    _actionInfo = GetRuntimeActionForType(type)
                };

                runtimeInfo._runtimeCollectionElementInfo = RuntimeInfo.Create(GetGenericCollectionElementType(type), tempCache);
                runtimeInfo._runtimeMembers = CreateRuntimeMemberInfo(type, tempCache).ToArray();

                return(runtimeInfo);
            }
예제 #2
0
        public static bool TryGet <T>(string key, out T value)
        {
            Check.Argument.IsNotNullOrEmpty(key, "key");

            return(InternalCache.TryGet(key, out value));
        }