I need to determine how closely one type is related to another for a custom
System.Reflecti on.Binder I am writing. This measure expresses through how
many classes one type is inheriting from another.
Example implementation:
public virtual int derivation_dist ance(Type formal, Type actual)
{
int result;
Type t;
t = actual;
result = 0;
while (t != null && t != formal) {
t = t.BaseType;
result++;
}
if (t == null) {
result = -1;
}
return result;
}
Complications arise when 'formal' is an interface. Ideally a breadth first
search of 'actual's implemented interfaces needs to be performed.
Unfortunately, there does not seem to be a way to ask a type for its
directly implemented interfaces. All that is possible is to call
Type::GetInterf aces which returns all interfaces (directly inherited and
indirectly).
Is there any way to find out directly inherited interfaces of a type or is
there another way of determining the derivation distance?
Andreas.
System.Reflecti on.Binder I am writing. This measure expresses through how
many classes one type is inheriting from another.
Example implementation:
public virtual int derivation_dist ance(Type formal, Type actual)
{
int result;
Type t;
t = actual;
result = 0;
while (t != null && t != formal) {
t = t.BaseType;
result++;
}
if (t == null) {
result = -1;
}
return result;
}
Complications arise when 'formal' is an interface. Ideally a breadth first
search of 'actual's implemented interfaces needs to be performed.
Unfortunately, there does not seem to be a way to ask a type for its
directly implemented interfaces. All that is possible is to call
Type::GetInterf aces which returns all interfaces (directly inherited and
indirectly).
Is there any way to find out directly inherited interfaces of a type or is
there another way of determining the derivation distance?
Andreas.