I wrote this function that is suppose to returnt rue if an array of
types(actually stuff returned by GetInterfaces) implements the interface Q.
private bool ContainsInterface<A, Q>(A[] list)
{
foreach (A a in list)
if (a is Q)
return true;
return false;
}
and is used like
ContainsInterface<Type, IEnumerable>(field.FieldType.GetInterfaces()))
So it checks the list for elements that implement IEnumerable.
I used this successfully in a "ContainsType"
ContainsType<Attribute, RawExcludeAttribute>(attributes)
Where its the same code. The above essentially just checks if any of the
attribute's in attributes is a RawExcludeAttribute. It works fine. My logic
was the same for interfaces but it doesn't work. (Maybe interfaces cannot
implement themselfs as "a is Q" is always false... yet when I debug I get
exactly these type for a and typeof(Q).
Even something like
foreach (A a in list)
{
Type t = typeof(Q);
if (a.GetType() == typeof(Q))
return true;
}
does not work.
In this case
t = + t {Name = "IEnumerable" FullName = "System.Collections.IEnumerable"}
System.Type {System.RuntimeType}
a = + a {Name = "IEnumerable" FullName = "System.Collections.IEnumerable"}
System.Type {System.RuntimeType}
So I don't see why they are not the same types ;/
Thanks,
Jon