You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
namespace Connected.Interop
|
|
|
|
|
{
|
|
|
|
|
public static class Generics
|
|
|
|
|
{
|
|
|
|
|
public static bool IsSubclassOfGenericType(this Type type, Type genericType)
|
|
|
|
|
{
|
|
|
|
|
var current = type.BaseType;
|
|
|
|
|
|
|
|
|
|
while (current is not null && current != typeof(object))
|
|
|
|
|
{
|
|
|
|
|
var currentType = current.IsGenericType ? current.GetGenericTypeDefinition() : current;
|
|
|
|
|
|
|
|
|
|
if (genericType == currentType)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
current = current.BaseType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|