refactor: 增加 Keyed 逻辑
This commit is contained in:
parent
ddb2b4ff1d
commit
24dcb24e24
|
|
@ -14,12 +14,15 @@ public static class BootstrapBlazoIP2RegionExtensions
|
|||
/// <param name="services"></param>
|
||||
public static IServiceCollection AddIP2RegionService(this IServiceCollection services, string path, CachePolicy cachePolicy = CachePolicy.Content)
|
||||
{
|
||||
services.AddSingleton<ISearcher>( provider =>
|
||||
services.AddSingleton<ISearcher>(provider =>
|
||||
{
|
||||
return new Searcher(cachePolicy, path);
|
||||
});
|
||||
#if NET8_0_OR_GREATER
|
||||
services.AddKeyedSingleton<ISearcher, Searcher>("IP2Region.Net");
|
||||
services.AddKeyedSingleton<ISearcher>("IP2Region.Net", (provider, _) =>
|
||||
{
|
||||
return new Searcher(cachePolicy, path);
|
||||
});
|
||||
#endif
|
||||
|
||||
return services;
|
||||
|
|
|
|||
Loading…
Reference in New Issue