@@ -470,13 +470,24 @@ private bool IsValidTypeMapping(Type implementationType, Type interfaceType)
470
470
471
471
if ( interfaceType . IsGenericTypeDefinition && implementationType . IsGenericTypeDefinition )
472
472
{
473
- var baseTypes = implementationType . GetBaseTypes ( ) . ToArray ( ) ;
473
+ var baseTypes = GetBaseTypes ( implementationType ) . ToArray ( ) ;
474
474
return baseTypes . Any ( t => t . IsGenericType && t . GetGenericTypeDefinition ( ) == interfaceType ) ;
475
475
}
476
476
477
477
return false ;
478
478
}
479
479
480
+ private static IEnumerable < Type > GetBaseTypes ( Type type )
481
+ {
482
+ if ( type . BaseType == null ) return type . GetInterfaces ( ) ;
483
+
484
+ return Enumerable . Repeat ( type . BaseType , 1 )
485
+ . Concat ( type . GetInterfaces ( ) )
486
+ . Concat ( type . GetInterfaces ( ) . SelectMany ( GetBaseTypes ) )
487
+ . Concat ( GetBaseTypes ( type . BaseType ) ) ;
488
+ }
489
+
490
+
480
491
private RegistrationKey CreateNamedInstanceDictionaryKey ( Type targetType )
481
492
{
482
493
return new RegistrationKey ( typeof ( IDictionary < , > ) . MakeGenericType ( typeof ( string ) , targetType ) , null ) ;
@@ -880,17 +891,4 @@ public string Name
880
891
881
892
#endif
882
893
#endregion
883
-
884
- internal static class TypeHelper
885
- {
886
- public static IEnumerable < Type > GetBaseTypes ( this Type type )
887
- {
888
- if ( type . BaseType == null ) return type . GetInterfaces ( ) ;
889
-
890
- return Enumerable . Repeat ( type . BaseType , 1 )
891
- . Concat ( type . GetInterfaces ( ) )
892
- . Concat ( type . GetInterfaces ( ) . SelectMany < Type , Type > ( GetBaseTypes ) )
893
- . Concat ( type . BaseType . GetBaseTypes ( ) ) ;
894
- }
895
- }
896
894
}
0 commit comments