Beispiel #1
0
        public static IEnumerable <PropertyInfo> GetPropertiesInHierarchy(
            this PropertyInfo property)
        {
            List <PropertyInfo> source = new List <PropertyInfo>()
            {
                property
            };

            PropertyInfoExtensions.CollectProperties(property, (IList <PropertyInfo>)source);
            return(source.Distinct <PropertyInfo>());
        }
Beispiel #2
0
        public static bool CanWriteExtended(this PropertyInfo propertyInfo)
        {
            if (propertyInfo.CanWrite)
            {
                return(true);
            }
            PropertyInfo declaredProperty = PropertyInfoExtensions.GetDeclaredProperty(propertyInfo);

            if (declaredProperty != (PropertyInfo)null)
            {
                return(declaredProperty.CanWrite);
            }
            return(false);
        }
Beispiel #3
0
        public static PropertyInfo GetPropertyInfoForSet(this PropertyInfo propertyInfo)
        {
            if (propertyInfo.CanWrite)
            {
                return(propertyInfo);
            }
            PropertyInfo declaredProperty = PropertyInfoExtensions.GetDeclaredProperty(propertyInfo);

            if ((object)declaredProperty != null)
            {
                return(declaredProperty);
            }
            return(propertyInfo);
        }
Beispiel #4
0
        private static void FindNextProperty(
            PropertyInfo property,
            IList <PropertyInfo> collection,
            bool getter)
        {
            MethodInfo methodInfo = getter ? property.Getter() : property.Setter();

            if (!(methodInfo != (MethodInfo)null))
            {
                return;
            }
            Type type = methodInfo.DeclaringType.BaseType();

            if (!(type != (Type)null) || !(type != typeof(object)))
            {
                return;
            }
            MethodInfo   baseMethod = methodInfo.GetBaseDefinition();
            PropertyInfo property1  = type.GetInstanceProperties().Select(p => new
            {
                p = p,
                candidateMethod = getter ? p.Getter() : p.Setter()
            }).Where(_param1 =>
            {
                if (_param1.candidateMethod != (MethodInfo)null)
                {
                    return(_param1.candidateMethod.GetBaseDefinition() == baseMethod);
                }
                return(false);
            }).Select(_param0 => _param0.p).FirstOrDefault <PropertyInfo>();

            if (!(property1 != (PropertyInfo)null))
            {
                return;
            }
            collection.Add(property1);
            PropertyInfoExtensions.CollectProperties(property1, collection);
        }
Beispiel #5
0
 private static void CollectProperties(PropertyInfo property, IList <PropertyInfo> collection)
 {
     PropertyInfoExtensions.FindNextProperty(property, collection, true);
     PropertyInfoExtensions.FindNextProperty(property, collection, false);
 }