Пример #1
0
        public static PropertyInfo LookupPropertyInfo(Type type, string propname)
        {
            if (type == null || propname == null)
            {
                return(null);
            }
            PropertyInfo propertyInfo = null;

            PropertyTest.TypeInfo typeInfo = null;
            foreach (PropertyTest.TypeInfo propertyInfoList in PropertyTest.PropertyInfoList)
            {
                if (propertyInfoList.t != type)
                {
                    continue;
                }
                typeInfo = propertyInfoList;
                foreach (PropertyInfo propertyInfo1 in propertyInfoList.plist)
                {
                    if (!PropertyTest.Insensitive.Equals(propertyInfo1.Name, propname))
                    {
                        continue;
                    }
                    propertyInfo = propertyInfo1;
                }
            }
            if (propertyInfo != null)
            {
                return(propertyInfo);
            }
            PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
            for (int i = 0; i < (int)properties.Length; i++)
            {
                PropertyInfo propertyInfo2 = properties[i];
                if (PropertyTest.Insensitive.Equals(propertyInfo2.Name, propname))
                {
                    if (typeInfo == null)
                    {
                        typeInfo = new PropertyTest.TypeInfo()
                        {
                            t = type
                        };
                        PropertyTest.PropertyInfoList.Add(typeInfo);
                    }
                    typeInfo.plist.Add(propertyInfo2);
                    return(propertyInfo2);
                }
            }
            return(null);
        }
Пример #2
0
        public static PropertyInfo LookupPropertyInfo(Type type, string propname)
        {
            if (type == null || propname == null)
            {
                return((PropertyInfo)null);
            }
            PropertyInfo propertyInfo1 = (PropertyInfo)null;

            PropertyTest.TypeInfo typeInfo1 = (PropertyTest.TypeInfo)null;
            foreach (PropertyTest.TypeInfo typeInfo2 in PropertyTest.PropertyInfoList)
            {
                if (typeInfo2.t == type)
                {
                    typeInfo1 = typeInfo2;
                    foreach (PropertyInfo propertyInfo2 in typeInfo2.plist)
                    {
                        if (PropertyTest.Insensitive.Equals(propertyInfo2.Name, propname))
                        {
                            propertyInfo1 = propertyInfo2;
                        }
                    }
                }
            }
            if (propertyInfo1 != null)
            {
                return(propertyInfo1);
            }
            foreach (PropertyInfo propertyInfo2 in type.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public))
            {
                if (PropertyTest.Insensitive.Equals(propertyInfo2.Name, propname))
                {
                    if (typeInfo1 == null)
                    {
                        typeInfo1   = new PropertyTest.TypeInfo();
                        typeInfo1.t = type;
                        PropertyTest.PropertyInfoList.Add((object)typeInfo1);
                    }
                    typeInfo1.plist.Add((object)propertyInfo2);
                    return(propertyInfo2);
                }
            }
            return((PropertyInfo)null);
        }