Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/MediatR/Registration/ServiceRegistrar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ private static bool CanBeCastTo(this Type pluggedType, Type pluginType)

if (pluggedType == pluginType) return true;

return pluginType.GetTypeInfo().IsAssignableFrom(pluggedType.GetTypeInfo());
return pluginType.IsAssignableFrom(pluggedType);
}

private static bool IsOpenGeneric(this Type type)
{
return type.GetTypeInfo().IsGenericTypeDefinition || type.GetTypeInfo().ContainsGenericParameters;
return type.IsGenericTypeDefinition || type.ContainsGenericParameters;
}

private static IEnumerable<Type> FindInterfacesThatClose(this Type pluggedType, Type templateType)
Expand All @@ -176,33 +176,33 @@ private static IEnumerable<Type> FindInterfacesThatClosesCore(Type pluggedType,

if (!pluggedType.IsConcrete()) yield break;

if (templateType.GetTypeInfo().IsInterface)
if (templateType.IsInterface)
{
foreach (
var interfaceType in
pluggedType.GetInterfaces()
.Where(type => type.GetTypeInfo().IsGenericType && (type.GetGenericTypeDefinition() == templateType)))
.Where(type => type.IsGenericType && (type.GetGenericTypeDefinition() == templateType)))
{
yield return interfaceType;
}
}
else if (pluggedType.GetTypeInfo().BaseType!.GetTypeInfo().IsGenericType &&
(pluggedType.GetTypeInfo().BaseType!.GetGenericTypeDefinition() == templateType))
else if (pluggedType.BaseType!.IsGenericType &&
(pluggedType.BaseType!.GetGenericTypeDefinition() == templateType))
{
yield return pluggedType.GetTypeInfo().BaseType!;
yield return pluggedType.BaseType!;
}

if (pluggedType.GetTypeInfo().BaseType == typeof(object)) yield break;
if (pluggedType.BaseType == typeof(object)) yield break;

foreach (var interfaceType in FindInterfacesThatClosesCore(pluggedType.GetTypeInfo().BaseType!, templateType))
foreach (var interfaceType in FindInterfacesThatClosesCore(pluggedType.BaseType!, templateType))
{
yield return interfaceType;
}
}

private static bool IsConcrete(this Type type)
{
return !type.GetTypeInfo().IsAbstract && !type.GetTypeInfo().IsInterface;
return !type.IsAbstract && !type.IsInterface;
}

private static void Fill<T>(this IList<T> list, T value)
Expand Down