Exemple #1
0
        public static Dictionary <string, PropertyInfo> GetTypeProperties(Type type)
        {
            ViReflectionCache.ReflectionCacheItem reflectionCacheItemByType = ViReflectionCache.GetReflectionCacheItemByType(type);
            Dictionary <string, PropertyInfo>     dictionary = reflectionCacheItemByType.Properties;

            if (dictionary == null)
            {
                PropertyInfo[] expr_19 = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
                dictionary = new Dictionary <string, PropertyInfo>(expr_19.Length);
                PropertyInfo[] array = expr_19;
                for (int i = 0; i < array.Length; i++)
                {
                    PropertyInfo propertyInfo = array[i];
                    string       key          = propertyInfo.Name.ToLower();
                    if (!dictionary.ContainsKey(key))
                    {
                        dictionary.Add(key, propertyInfo);
                    }
                    else if (dictionary[key].PropertyType.IsAssignableFrom(propertyInfo.PropertyType))
                    {
                        dictionary[key] = propertyInfo;
                    }
                }
                reflectionCacheItemByType.Properties = dictionary;
            }
            return(dictionary);
        }
Exemple #2
0
        public static ConstructorInfo GetTypeDefaultConstructor(Type type)
        {
            ViReflectionCache.ReflectionCacheItem reflectionCacheItemByType = ViReflectionCache.GetReflectionCacheItemByType(type);
            ConstructorInfo constructorInfo = reflectionCacheItemByType.DefaultConstructor;

            if (constructorInfo == null)
            {
                constructorInfo = type.GetConstructor(Type.EmptyTypes);
                reflectionCacheItemByType.DefaultConstructor = constructorInfo;
            }
            return(constructorInfo);
        }