// Token: 0x06000E2C RID: 3628 RVA: 0x00051C78 File Offset: 0x0004FE78 public static bool InheritsGenericDefinition(Type type, Type genericClassDefinition, [Nullable(2)] out Type implementingType) { ValidationUtils.ArgumentNotNull(type, "type"); ValidationUtils.ArgumentNotNull(genericClassDefinition, "genericClassDefinition"); if (!genericClassDefinition.IsClass() || !genericClassDefinition.IsGenericTypeDefinition()) { throw new ArgumentNullException("'{0}' is not a generic class definition.".FormatWith(CultureInfo.InvariantCulture, genericClassDefinition)); } return(ReflectionUtils.InheritsGenericDefinitionInternal(type, genericClassDefinition, out implementingType)); }
public static bool InheritsGenericDefinition(Type type, Type genericClassDefinition, out Type implementingType) { ValidationUtils.ArgumentNotNull((object)type, "type"); ValidationUtils.ArgumentNotNull((object)genericClassDefinition, "genericClassDefinition"); if (!TypeExtensions.IsClass(genericClassDefinition) || !TypeExtensions.IsGenericTypeDefinition(genericClassDefinition)) { throw new ArgumentNullException(StringUtils.FormatWith("'{0}' is not a generic class definition.", (IFormatProvider)CultureInfo.InvariantCulture, (object)genericClassDefinition)); } else { return(ReflectionUtils.InheritsGenericDefinitionInternal(type, genericClassDefinition, out implementingType)); } }
public static bool InheritsGenericDefinition( Type type, Type genericClassDefinition, out Type implementingType) { ValidationUtils.ArgumentNotNull((object)type, nameof(type)); ValidationUtils.ArgumentNotNull((object)genericClassDefinition, nameof(genericClassDefinition)); if (!genericClassDefinition.IsClass() || !genericClassDefinition.IsGenericTypeDefinition()) { throw new ArgumentNullException("'{0}' is not a generic class definition.".FormatWith((IFormatProvider)CultureInfo.InvariantCulture, (object)genericClassDefinition)); } return(ReflectionUtils.InheritsGenericDefinitionInternal(type, genericClassDefinition, out implementingType)); }
private static bool InheritsGenericDefinitionInternal(Type currentType, Type genericClassDefinition, out Type implementingType) { if (currentType.IsGenericType() && genericClassDefinition == currentType.GetGenericTypeDefinition()) { implementingType = currentType; return(true); } if (currentType.BaseType() == null) { implementingType = null; return(false); } return(ReflectionUtils.InheritsGenericDefinitionInternal(currentType.BaseType(), genericClassDefinition, out implementingType)); }
private static bool InheritsGenericDefinitionInternal(Type currentType, Type genericClassDefinition, out Type implementingType) { if (TypeExtensions.IsGenericType(currentType)) { Type genericTypeDefinition = currentType.GetGenericTypeDefinition(); if (genericClassDefinition == genericTypeDefinition) { implementingType = currentType; return(true); } } if (TypeExtensions.BaseType(currentType) != null) { return(ReflectionUtils.InheritsGenericDefinitionInternal(TypeExtensions.BaseType(currentType), genericClassDefinition, out implementingType)); } implementingType = (Type)null; return(false); }