File tree Expand file tree Collapse file tree
src/components/BootstrapBlazor.IP2Region Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- // Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
1+ // Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33// Website: https://www.blazor.zone or https://argozhang.github.io/
44
@@ -15,14 +15,19 @@ public static class ServiceCollectionExtensions
1515 /// 添加 IP2RegionService 服务
1616 /// </summary>
1717 /// <param name="services"></param>
18- public static IServiceCollection AddBootstrapBlazorIP2RegionService ( this IServiceCollection services )
18+ /// <param name="configureOptions"></param>
19+ public static IServiceCollection AddBootstrapBlazorIP2RegionService ( this IServiceCollection services , Action < IP2RegionOptions > ? configureOptions = null )
1920 {
2021 services . AddSingleton < IIpLocatorProvider , IP2RegionService > ( ) ;
2122#if NET8_0_OR_GREATER
2223 services . AddKeyedSingleton < IIpLocatorProvider , IP2RegionService > ( "BootstrapBlazor.IP2Region" ) ;
2324#endif
2425
2526 services . AddOptionsMonitor < IP2RegionOptions > ( ) ;
27+ services . Configure < IP2RegionOptions > ( options =>
28+ {
29+ configureOptions ? . Invoke ( options ) ;
30+ } ) ;
2631 return services ;
2732 }
2833}
Original file line number Diff line number Diff line change 1- // Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
1+ // Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33// Website: https://www.blazor.zone or https://argozhang.github.io/
44
5+ using IP2Region . Net . XDB ;
6+
57namespace BootstrapBlazor . Components ;
68
79/// <summary>
@@ -13,4 +15,9 @@ public class IP2RegionOptions
1315 /// 获取/设置 IP2Region 数据文件路径
1416 /// </summary>
1517 public string ? XdbPath { get ; set ; }
18+
19+ /// <summary>
20+ /// 获得/设置 缓存策略 默认 <see cref="CachePolicy.Content"/>
21+ /// </summary>
22+ public CachePolicy CachePolicy { get ; set ; } = CachePolicy . Content ;
1623}
You can’t perform that action at this time.
0 commit comments