Esempio n. 1
0
        private Property_Access_Mode GetAccess(PropertyInfo property)
        {
            Property_Access_Mode p = 0;

            if (property.CanRead && property.GetMethod.IsPublic)
            {
                p |= Property_Access_Mode.Read;
            }

            if (property.CanWrite && property.SetMethod.IsPublic)
            {
                p |= Property_Access_Mode.Write;
            }

            return(p);
        }
Esempio n. 2
0
        public Dictionary <string, PropertyInfo> GetProperties(Type type, Property_Access_Mode access)
        {
            Dictionary <string, PropertyInfo> pd = new Dictionary <string, PropertyInfo>();

            GetPropertiesInternal(type, pd, access);

            Type baseType = type.BaseType;

            while (baseType != null && baseType != typeof(object))
            {
                GetPropertiesInternal(baseType, pd, access);
                baseType = baseType.BaseType;
            }

            return(pd);
        }
Esempio n. 3
0
        private void GetPropertiesInternal(Type type, Dictionary <string, PropertyInfo> pd, Property_Access_Mode access)
        {
            PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);

            foreach (PropertyInfo property in properties)
            {
                Property_Access_Mode pam = GetAccess(property);

                if (!access.HasFlag(pam))
                {
                    continue;
                }

                if (pd.ContainsKey(property.Name))
                {
                    continue;
                }

                pd.Add(property.Name, property);
            }
        }