/// <summary> /// Determines whether this TypeToPropertyInfoDictionaryAssociation contains a specific value. /// </summary> /// <param name="value"> /// The PropertyInfoDictionary value to locate in this TypeToPropertyInfoDictionaryAssociation. /// </param> /// <returns> /// true if this TypeToPropertyInfoDictionaryAssociation contains an element with the specified value; /// otherwise, false. /// </returns> public virtual bool ContainsValue(PropertyInfoDictionary value) { foreach (PropertyInfoDictionary item in this.Dictionary.Values) { if (item == value) { return(true); } } return(false); }
internal static PropertyInfo GetPropertyInfo(object o, string propertyName) { PropertyInfo propInfo = o.GetType().GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance); if (propInfo != null) { return(propInfo); } lock (_parameterInfoCache) { Type targetType = o.GetType(); PropertyInfoDictionary cache = _parameterInfoCache[targetType]; if (cache == null) { cache = BuildPropertyInfoDictionary(targetType); _parameterInfoCache[targetType] = cache; } return(cache[propertyName.ToLower()]); } }
private static PropertyInfo GetPropertyInfo(Type targetType, string propertyName) { if (propertyName != "") { PropertyInfo propInfo = targetType.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance); if (propInfo != null) { return(propInfo); } } lock (_parameterInfoCache) { PropertyInfoDictionary cache = _parameterInfoCache[targetType]; if (cache == null) { cache = BuildPropertyInfoDictionary(targetType); _parameterInfoCache[targetType] = cache; } return(cache[propertyName.ToLower()]); } }
private static PropertyInfoDictionary BuildPropertyInfoDictionary(Type t) { PropertyInfoDictionary retVal = new PropertyInfoDictionary(); foreach (PropertyInfo propInfo in t.GetProperties()) { if (propInfo.IsDefined(typeof(ArrayParameterAttribute), false)) { ArrayParameterAttribute[] attributes = (ArrayParameterAttribute[])propInfo.GetCustomAttributes(typeof(ArrayParameterAttribute), false); retVal[attributes[0].ElementName.ToLower()] = propInfo; } else { retVal[propInfo.Name.ToLower()] = propInfo; } if (propInfo.IsDefined(typeof(DefaultParameterAttribute), false)) { retVal[""] = propInfo; } } return(retVal); }
/// <summary> /// Adds an element with the specified key and value to this TypeToPropertyInfoDictionaryAssociation. /// </summary> /// <param name="key"> /// The Type key of the element to add. /// </param> /// <param name="value"> /// The PropertyInfoDictionary value of the element to add. /// </param> public virtual void Add(Type key, PropertyInfoDictionary value) { this.Dictionary.Add(key, value); }
/// <summary> /// Determines whether this TypeToPropertyInfoDictionaryAssociation contains a specific value. /// </summary> /// <param name="value"> /// The PropertyInfoDictionary value to locate in this TypeToPropertyInfoDictionaryAssociation. /// </param> /// <returns> /// true if this TypeToPropertyInfoDictionaryAssociation contains an element with the specified value; /// otherwise, false. /// </returns> public virtual bool ContainsValue(PropertyInfoDictionary value) { foreach (PropertyInfoDictionary item in this.Dictionary.Values) { if (item == value) return true; } return false; }
private static PropertyInfoDictionary BuildPropertyInfoDictionary(Type t) { PropertyInfoDictionary retVal = new PropertyInfoDictionary(); foreach (PropertyInfo propInfo in t.GetProperties()) { if (propInfo.IsDefined(typeof(ArrayParameterAttribute), false)) { ArrayParameterAttribute[] attributes = (ArrayParameterAttribute[])propInfo.GetCustomAttributes(typeof(ArrayParameterAttribute), false); retVal[attributes[0].ElementName.ToLower()] = propInfo; } else { retVal[propInfo.Name.ToLower()] = propInfo; } if (propInfo.IsDefined(typeof(DefaultParameterAttribute), false)) retVal[""] = propInfo; } return retVal; }