Example #1
0
        public IEnumerable <PropertyInfo> GetProperties(Type targetType, BindingFlags bindingAttr)
        {
            XValidation.ArgumentNotNull(targetType, nameof(targetType));

            List <PropertyInfo> propertyInfos = new List <PropertyInfo>(targetType.GetProperties(bindingAttr));

            // GetProperties on an interface doesn't return properties from its interfaces
            if (XTypesBasic.IsInterface(targetType))
            {
                foreach (Type i in targetType.GetInterfaces())
                {
                    propertyInfos.AddRange(i.GetProperties(bindingAttr));
                }
            }

            XProperties.Api.GetChildPrivateProperties(propertyInfos, targetType, bindingAttr);

            // a base class private getter/setter will be inaccessible unless the property was gotten from the base class
            for (int i = 0; i < propertyInfos.Count; i++)
            {
                PropertyInfo member = propertyInfos[i];
                if (member.DeclaringType != targetType)
                {
                    PropertyInfo declaredMember = (PropertyInfo)GetMemberInfoFromType(member.DeclaringType, member);
                    propertyInfos[i] = declaredMember;
                }
            }

            return(propertyInfos);
        }
Example #2
0
 public static bool IsInterface(this System.Type type)
 {
     return(XTypesBasic.IsInterface(type));
 }