/// <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);
 }
예제 #2
0
        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()]);
            }
        }
예제 #3
0
        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()]);
            }
        }
예제 #4
0
        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;
 }
 /// <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);
 }
예제 #8
0
        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;
        }