public static bool IsSubclassOfRawGeneric(Type generic, Type toCheck, out Type actualGeneric)
{
while (toCheck != null && toCheck != typeof(object))
{
var cur = toCheck.IsGenericType ? toCheck.GetGenericTypeDefinition() : toCheck;
if (generic == cur)
{
actualGeneric = toCheck;
return true;
}
toCheck = toCheck.BaseType;
}
actualGeneric = null;
return false;
}