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