CanCache() public static méthode

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
Résultat bool
Exemple #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);
        }
Exemple #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);
        }