Make GetPropertiesIncludingInherited private to its consuming class
Just because it's not being used anywhere else currently
This commit is contained in:
parent
ef1b670b8b
commit
a386444b64
|
|
@ -55,8 +55,8 @@ namespace Microsoft.AspNetCore.Blazor.Components
|
|||
private Action<IComponent> CreateInitializer(Type type)
|
||||
{
|
||||
// Do all the reflection up front
|
||||
var injectableProperties = type.GetTypeInfo()
|
||||
.GetPropertiesIncludingInherited(_injectablePropertyBindingFlags)
|
||||
var injectableProperties =
|
||||
GetPropertiesIncludingInherited(type, _injectablePropertyBindingFlags)
|
||||
.Where(p => p.GetCustomAttribute<InjectAttribute>() != null);
|
||||
var injectables = injectableProperties.Select(property =>
|
||||
{
|
||||
|
|
@ -114,5 +114,21 @@ namespace Microsoft.AspNetCore.Blazor.Components
|
|||
public void SetValue(object target, object value)
|
||||
=> _setterDelegate((TTarget)target, (TValue)value);
|
||||
}
|
||||
|
||||
private static IEnumerable<PropertyInfo> GetPropertiesIncludingInherited(
|
||||
Type type, BindingFlags bindingFlags)
|
||||
{
|
||||
while (type != null)
|
||||
{
|
||||
var properties = type.GetProperties(bindingFlags)
|
||||
.Where(prop => prop.DeclaringType == type);
|
||||
foreach (var property in properties)
|
||||
{
|
||||
yield return property;
|
||||
}
|
||||
|
||||
type = type.BaseType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Blazor
|
||||
{
|
||||
public static class TypeInfoExtensions
|
||||
{
|
||||
public static IEnumerable<PropertyInfo> GetPropertiesIncludingInherited(this TypeInfo typeInfo, BindingFlags bindingFlags)
|
||||
{
|
||||
while (typeInfo != null)
|
||||
{
|
||||
var properties = typeInfo.GetProperties(bindingFlags)
|
||||
.Where(prop => prop.ReflectedType == prop.DeclaringType);
|
||||
foreach (var property in properties)
|
||||
yield return property;
|
||||
|
||||
typeInfo = typeInfo.BaseType?.GetTypeInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue