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); }
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); }
private static ViReflectionCache.ReflectionCacheItem GetReflectionCacheItemByType(Type type) { ViReflectionCache.ReflectionCacheItem reflectionCacheItem = null; string fullName = type.FullName; object @lock = ViReflectionCache._lock; lock (@lock) { if (!ViReflectionCache._cache.TryGetValue(fullName, out reflectionCacheItem)) { reflectionCacheItem = new ViReflectionCache.ReflectionCacheItem(type); ViReflectionCache._cache[fullName] = reflectionCacheItem; } } return(reflectionCacheItem); }
public static Type GetTypeByRemoteTypeAndName(Type remoteType, string typeName) { Type type = null; string text = remoteType.Namespace + "." + typeName; ViReflectionCache.ReflectionCacheItem reflectionCacheItem = null; object @lock = ViReflectionCache._lock; lock (@lock) { if (!ViReflectionCache._cache.TryGetValue(text, out reflectionCacheItem)) { type = remoteType.Assembly.GetType(text); ViReflectionCache._cache[text] = new ViReflectionCache.ReflectionCacheItem(type); } else { type = reflectionCacheItem.Type; } } return(type); }