|
|
|
@ -1182,11 +1182,23 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
return (TKey?) GetConverter().ConvertFromInvariantString(identifier); |
|
|
|
// Optimization: if the key is a string, directly return it as-is.
|
|
|
|
if (typeof(TKey) == typeof(string)) |
|
|
|
{ |
|
|
|
return (TKey?) (object?) identifier; |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
var converter = |
|
|
|
#if SUPPORTS_TYPE_DESCRIPTOR_TYPE_REGISTRATION
|
|
|
|
TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); |
|
|
|
#else
|
|
|
|
TypeDescriptor.GetConverter(typeof(TKey)); |
|
|
|
#endif
|
|
|
|
|
|
|
|
[UnconditionalSuppressMessage("Trimming", "IL2026", |
|
|
|
Justification = "Only primitive types are supported as entity keys.")] |
|
|
|
static TypeConverter GetConverter() => TypeDescriptor.GetConverter(typeof(TKey)); |
|
|
|
return (TKey?) converter.ConvertFromInvariantString(identifier); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -1201,10 +1213,22 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
return GetConverter().ConvertToInvariantString(identifier); |
|
|
|
// Optimization: if the key is a string, directly return it as-is.
|
|
|
|
if (identifier is string value) |
|
|
|
{ |
|
|
|
return value; |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
var converter = |
|
|
|
#if SUPPORTS_TYPE_DESCRIPTOR_TYPE_REGISTRATION
|
|
|
|
TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); |
|
|
|
#else
|
|
|
|
TypeDescriptor.GetConverter(typeof(TKey)); |
|
|
|
#endif
|
|
|
|
|
|
|
|
[UnconditionalSuppressMessage("Trimming", "IL2026", |
|
|
|
Justification = "Only primitive types are supported as entity keys.")] |
|
|
|
static TypeConverter GetConverter() => TypeDescriptor.GetConverter(typeof(TKey)); |
|
|
|
return converter.ConvertToInvariantString(identifier); |
|
|
|
} |
|
|
|
} |
|
|
|
} |