Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit bfa898b

Browse files
committed
eliniate TypeHelper class
1 parent 975038c commit bfa898b

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

BoDi/BoDi.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,24 @@ private bool IsValidTypeMapping(Type implementationType, Type interfaceType)
470470

471471
if (interfaceType.IsGenericTypeDefinition && implementationType.IsGenericTypeDefinition)
472472
{
473-
var baseTypes = implementationType.GetBaseTypes().ToArray();
473+
var baseTypes = GetBaseTypes(implementationType).ToArray();
474474
return baseTypes.Any(t => t.IsGenericType && t.GetGenericTypeDefinition() == interfaceType);
475475
}
476476

477477
return false;
478478
}
479479

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+
480491
private RegistrationKey CreateNamedInstanceDictionaryKey(Type targetType)
481492
{
482493
return new RegistrationKey(typeof(IDictionary<,>).MakeGenericType(typeof(string), targetType), null);
@@ -880,17 +891,4 @@ public string Name
880891

881892
#endif
882893
#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-
}
896894
}

0 commit comments

Comments
 (0)