Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
mapper: Correct GetInterfaceType(Type,string)
Browse files Browse the repository at this point in the history
In recent commits I had neglected to consider that some users of
dbus-sharp will be subclassing MarshalByRefObject.

This commit corrects that, adding a simple GetHierarchy function to
return the type and its ancestors.
  • Loading branch information
arfbtwn committed Feb 25, 2015
1 parent 7ac412e commit 50cee72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ExportObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public MethodCaller GetPropertyAllCall (string iface)

if (null == calls.All) {
Type it = Mapper.GetInterfaceType (ObjectType, iface);
calls.All = null == it ? null : TypeImplementer.GenGetAllCall (it);
calls.All = TypeImplementer.GenGetAllCall (it);
}

return calls.All;
Expand Down
17 changes: 16 additions & 1 deletion src/Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,22 @@ public static string GetArgumentName (ICustomAttributeProvider attrProvider, str

public static Type GetInterfaceType(Type type, string iface)
{
return type.GetInterfaces ().FirstOrDefault (x => iface == GetInterfaceName (x));
return type.GetInterfaces()
.Concat(GetHierarchy(type))
.FirstOrDefault (x => iface == GetInterfaceName (x));
}

private static IEnumerable<Type> GetHierarchy(Type type)
{
if (IsPublic (type)) {
yield return type;
}

foreach (var super in GetHierarchy (type.BaseType)) {
if (IsPublic (type)) {
yield return super;
}
}
}

public static IEnumerable<PropertyInfo> GetPublicProperties (Type type)
Expand Down

0 comments on commit 50cee72

Please sign in to comment.