Fix bound types not considering interfaces inheriting from other interfaces

This commit is contained in:
Deukhoofd 2019-01-22 14:39:29 +01:00
parent 613e9dcb09
commit 750d5dab8d
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 15 additions and 3 deletions

View File

@ -36,7 +36,7 @@ namespace Upsilon.BoundTypes
Properties = new Dictionary<string, UserDataBoundProperty>(),
Name = name
};
var fields = backingType.GetFields().Select(x => new UserDataBoundProperty()
var fields = backingType.GetFields(BindingFlags.Public | BindingFlags.Instance).Select(x => new UserDataBoundProperty()
{
Name = x.Name,
ActualType = x.FieldType.Name,
@ -46,7 +46,19 @@ namespace Upsilon.BoundTypes
{
obj.Properties.Add(f.Name.ToLowerInvariant(), f);
}
var properties = backingType.GetProperties().Select(x => new UserDataBoundProperty()
PropertyInfo[] realProperties;
if (backingType.IsInterface)
{
realProperties = new[]{backingType}
.Concat(backingType.GetInterfaces())
.SelectMany(x => x.GetProperties(BindingFlags.Public | BindingFlags.Instance)).ToArray();
}
else
{
realProperties = backingType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
}
var properties = realProperties.Select(x => new UserDataBoundProperty()
{
Name = x.Name,
ActualType = x.PropertyType.Name,
@ -57,7 +69,7 @@ namespace Upsilon.BoundTypes
obj.Properties.Add(f.Name.ToLowerInvariant(), f);
}
var methods = new Dictionary<string, UserDataBoundMethod>();
var backingMethods = backingType.GetMethods();
var backingMethods = backingType.GetMethods(BindingFlags.Public | BindingFlags.Instance);
foreach (var backingMethod in backingMethods)
{
if (backingMethod.IsSpecialName)