Esempio n. 1
0
        internal static PropertyInfoList GetPropertyListCache(Type objectType)
        {
            var cache             = PropertyInfoCache;
            PropertyInfoList list = null;
            var found             = false;

            try
            {
                found = cache.TryGetValue(objectType, out list);
            }
            catch
            { /* failure will drop into !found block */ }
            if (!found)
            {
                lock (cache)
                {
                    if (!(cache.TryGetValue(objectType, out list)))
                    {
                        list = new PropertyInfoList();
                        cache.Add(objectType, list);
                    }
                }
            }
            return(list);
        }
Esempio n. 2
0
        internal static PropertyInfoList GetPropertyListCache(Type objectType)
        {
            var cache = PropertyInfoCache;

#if NET5_0_OR_GREATER
            var found = cache.TryGetValue(objectType, out var listInfo);

            var list = listInfo?.Item2;

            if (!found)
            {
                lock (cache)
                {
                    found = cache.TryGetValue(objectType, out listInfo);

                    if (!found)
                    {
                        list = new PropertyInfoList();

                        var cacheInstance = AssemblyLoadContextManager.CreateCacheInstance(objectType, list, OnAssemblyLoadContextUnload);

                        cache.Add(objectType, cacheInstance);

                        FieldDataManager.ForceStaticFieldInit(objectType);
                    }
                }
            }
#else
            var found = cache.TryGetValue(objectType, out PropertyInfoList list);

            if (!found)
            {
                lock (cache)
                {
                    found = cache.TryGetValue(objectType, out list);

                    if (!found)
                    {
                        list = new PropertyInfoList();

                        cache.Add(objectType, list);

                        FieldDataManager.ForceStaticFieldInit(objectType);
                    }
                }
            }
#endif

            return(list);
        }
        public static PropertyInfoList GetPropertyListCache(Type objectType)
        {
            var cache             = PropertyInfoCache;
            PropertyInfoList list = null;

            if (!(cache.TryGetValue(objectType, out list)))
            {
                lock (cache)
                {
                    if (!(cache.TryGetValue(objectType, out list)))
                    {
                        list = new PropertyInfoList();
                        cache.Add(objectType, list);
                    }
                }
            }
            return(list);
        }
Esempio n. 4
0
        internal static PropertyInfoList GetPropertyListCache(Type objectType)
        {
            var cache = PropertyInfoCache;
            var found = cache.TryGetValue(objectType, out PropertyInfoList list);

            if (!found)
            {
                lock (cache)
                {
                    found = cache.TryGetValue(objectType, out list);
                    if (!found)
                    {
                        list = new PropertyInfoList();
                        cache.Add(objectType, list);
                        FieldDataManager.ForceStaticFieldInit(objectType);
                    }
                }
            }
            return(list);
        }