private static bool DoesTypeImplement(Type baseType, Type targetType) { if (baseType.IsAssignableFrom(targetType)) { return(true); } if (!baseType.IsGenericTypeDefinition) { return(false); } return(PlatformTypes.IsGenericTypeDefinitionOf(baseType, targetType)); }
protected TypeHandler DetermineBestHandler(TypeHandler handler, Type type) { this.InitializeIfNecessary(); Type type1 = typeof(object); Type implementingType = typeof(object); foreach (TypeHandler typeHandler in this.handlers) { Type baseType = this.GetBaseType(typeHandler); if (!(baseType != null) || !baseType.IsAssignableFrom(type) && (!baseType.IsGenericTypeDefinition || !PlatformTypes.IsGenericTypeDefinitionOf(baseType, type)) || !type1.IsAssignableFrom(baseType) && (!baseType.IsInterface || baseType.IsAssignableFrom(implementingType))) { continue; } handler = typeHandler; type1 = baseType; implementingType = this.GetImplementingType(baseType, type); } return(handler); }