Пример #1
0
        public static IReflectionProperties Get(Type type)
        {
            lock (theLock)
            {
                if (cache == null)
                {
                    cache = new Dictionary <Type, IReflectionProperties>();
                }

                if (!cache.TryGetValue(type, out IReflectionProperties dict))
                {
                    dict = TypeHelper.GetPropertiesDict(type);
                    cache.Add(type, dict);
                }

                return(dict);
            }
        }
Пример #2
0
        /// <summary>
        /// Get the properties of a generic type.
        /// </summary>
        public static IReflectionProperties <T> GetProperties(Type type)
        {
            IReflectionProperties <T> properties;

            lock (typesDict)
            {
                if (!typesDict.ContainsKey(type))
                {
                    properties = TypeHelper.GetPropertiesDict <T>(type);
                    typesDict.Add(type, properties);
                }
                else
                {
                    properties = typesDict[type];
                }
            }

            return(properties);
        }