|
|
|
@ -34,31 +34,34 @@ namespace OpenIddict.Core |
|
|
|
throw new ArgumentException("The second parameter must be a generic type definition.", nameof(definition)); |
|
|
|
} |
|
|
|
|
|
|
|
for (var candidate = type.GetTypeInfo(); candidate != null; candidate = candidate.BaseType?.GetTypeInfo()) |
|
|
|
if (definition.GetTypeInfo().IsInterface) |
|
|
|
{ |
|
|
|
if (!candidate.IsGenericType && !candidate.AsType().IsConstructedGenericType) |
|
|
|
foreach (var contract in type.GetInterfaces()) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (!contract.GetTypeInfo().IsGenericType && !contract.IsConstructedGenericType) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (candidate.GetGenericTypeDefinition() == definition) |
|
|
|
{ |
|
|
|
return candidate.AsType(); |
|
|
|
if (contract.GetGenericTypeDefinition() == definition) |
|
|
|
{ |
|
|
|
return contract; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (definition.GetTypeInfo().IsInterface) |
|
|
|
else |
|
|
|
{ |
|
|
|
for (var candidate = type; candidate != null; candidate = candidate.GetTypeInfo().BaseType) |
|
|
|
{ |
|
|
|
foreach (var contract in candidate.AsType().GetInterfaces().Select(contract => contract.GetTypeInfo())) |
|
|
|
if (!candidate.GetTypeInfo().IsGenericType && !candidate.IsConstructedGenericType) |
|
|
|
{ |
|
|
|
if (!contract.IsGenericType && !contract.AsType().IsConstructedGenericType) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (contract.GetGenericTypeDefinition() == definition) |
|
|
|
{ |
|
|
|
return contract.AsType(); |
|
|
|
} |
|
|
|
if (candidate.GetGenericTypeDefinition() == definition) |
|
|
|
{ |
|
|
|
return candidate; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|