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.
Connected.Framework/Connected.Interop/Generics.cs

23 lines
459 B

2 years ago
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;
}
}
}