public static bool IsSubclassOf(this Type type, GenericType baseType) { while (type != null && type != CLRRootType) { if (type.IsGenericType) { if (type.GetGenericTypeDefinition() == baseType.GenericTypeDefinition) { return(true); } } type = type.BaseType; } return(false); }
public static bool IsSubclassOf(this object obj, GenericType baseType) { return(obj.GetType().IsSubclassOf(baseType)); }
public static bool TryConvert(Type type, out GenericType result) { result = CanConvertFrom(type) ? (GenericType)type : null; return(result != null); }
public static bool IsSubclassOfGeneric(this Type type, Type baseType) //??? { return(GenericType.CanConvertFrom(baseType) && type.IsSubclassOf((GenericType)baseType)); }
public static IEnumerable <T> OfType <T>(this IEnumerable <T> source) { var genericType = new GenericType(typeof(T)); return(source.Where(x => x.IsSubclassOf(genericType))); }