CanCache() public static method

We can cache references to types, as long as they aren't in collectible assemblies. Unfortunately, we can't really distinguish between different flavors of assemblies. But, we can at least create a cache for types in mscorlib (so we get the primitives, etc).
public static CanCache ( this t ) : bool
t this
return bool
示例#1
0
        internal static ParameterInfo[] GetParametersCached(this MethodBase method)
        {
            ParameterInfo[] pis;
            lock (_ParamInfoCache) {
                if (!_ParamInfoCache.TryGetValue(method, out pis))
                {
                    pis = method.GetParameters();

                    Type t = method.DeclaringType;
                    if (t != null && TypeUtils.CanCache(t))
                    {
                        _ParamInfoCache[method] = pis;
                    }
                }
            }
            return(pis);
        }
示例#2
0
        internal static ParameterInfo[] GetParametersCached(this MethodBase method)
        {
            ParameterInfo[] pis;
            CacheDict <MethodBase, ParameterInfo[]> pic = s_paramInfoCache;

            if (!pic.TryGetValue(method, out pis))
            {
                pis = method.GetParameters();

                Type t = method.DeclaringType;
                if (t != null && TypeUtils.CanCache(t))
                {
                    pic[method] = pis;
                }
            }

            return(pis);
        }