Skip to content

Commit 6bb83da

Browse files
committed
Cosmetics
1 parent f438163 commit 6bb83da

1 file changed

Lines changed: 17 additions & 20 deletions

File tree

src/AngleSharp.Js/Extensions/ReflectionExtensions.cs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ public static String[] GetParameterNames(this MethodInfo method) =>
1818
public static Object GetDefaultValue(this Type type) =>
1919
type.GetTypeInfo().IsValueType ? Activator.CreateInstance(type) : null;
2020

21-
public static IEnumerable<Type> GetExtensionTypes(this IEnumerable<Assembly> libs, String name)
22-
{
23-
return libs
24-
.SelectMany(m => m.ExportedTypes)
25-
.Where(m => m.GetCustomAttributes<DomExposedAttribute>().Any(n => n.Target.Is(name)))
26-
.ToArray();
27-
}
21+
public static IEnumerable<Type> GetExtensionTypes(this IEnumerable<Assembly> libs, String name) => libs
22+
.SelectMany(m => m.ExportedTypes)
23+
.Where(m => m.GetCustomAttributes<DomExposedAttribute>().Any(n => n.Target.Is(name)))
24+
.ToArray();
2825

2926
public static IEnumerable<Type> GetTypeTree(this Type root)
3027
{
@@ -92,29 +89,29 @@ public static String GetOfficialName(this Type currentType, Type baseType)
9289

9390
public static PropertyInfo GetInheritedProperty(this Type type, String propertyName, BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.Instance)
9491
{
95-
if (!type.IsInterface)
92+
if (type.IsInterface)
9693
{
97-
return type.GetProperty(propertyName, bindingAttr);
94+
return type.GetInterfaces()
95+
.Union(new[] { type })
96+
.Select(i => i.GetProperty(propertyName, bindingAttr))
97+
.Where(propertyInfo => propertyInfo != null)
98+
.FirstOrDefault();
9899
}
99100

100-
return type.GetInterfaces()
101-
.Union(new [] { type })
102-
.Select(i => i.GetProperty(propertyName, bindingAttr))
103-
.Where(propertyInfo => propertyInfo != null)
104-
.FirstOrDefault();
101+
return type.GetProperty(propertyName, bindingAttr);
105102
}
106103

107104
public static IEnumerable<PropertyInfo> GetInheritedProperties(this Type type, BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.Instance)
108105
{
109-
if (!type.IsInterface)
106+
if (type.IsInterface)
110107
{
111-
return type.GetProperties(bindingAttr);
108+
return type.GetInterfaces()
109+
.Union(new[] { type })
110+
.SelectMany(i => i.GetProperties(bindingAttr))
111+
.Distinct();
112112
}
113113

114-
return type.GetInterfaces()
115-
.Union(new [] { type })
116-
.SelectMany(i => i.GetProperties(bindingAttr))
117-
.Distinct();
114+
return type.GetProperties(bindingAttr);
118115
}
119116
}
120117
}

0 commit comments

Comments
 (0)