コード例 #1
0
 /// <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
ファイル: PropertyHelper.cs プロジェクト: NecroSharper/WCell
        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
ファイル: PropertyHelper.cs プロジェクト: NecroSharper/WCell
        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
ファイル: PropertyHelper.cs プロジェクト: NecroSharper/WCell
        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);
        }
コード例 #5
0
 /// <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);
 }
コード例 #6
0
 /// <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;
 }
コード例 #7
0
 /// <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
ファイル: PropertyHelper.cs プロジェクト: KroneckerX/WCell
        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;
        }