コード例 #1
0
ファイル: PropertyInfoManager.cs プロジェクト: plum3801/csla
        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);
        }
コード例 #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);
        }
コード例 #3
0
        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);
        }
コード例 #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);
        }