File tree Expand file tree Collapse file tree 5 files changed +12
-25
lines changed
src/BootstrapBlazor.Server Expand file tree Collapse file tree 5 files changed +12
-25
lines changed Original file line number Diff line number Diff line change 44 <span >@Label </span >
55 <Select Value =" @SelectedCulture" OnSelectedItemChanged =" @SetCulture" >
66 <Options >
7- @foreach ( var kv in BootstrapOptions .CurrentValue .GetSupportedCultures ())
7+ @foreach ( var kv in BootstrapOptions .Value .GetSupportedCultures ())
88 {
99 <SelectOption Text =" @GetDisplayName(kv)" Value =" @kv.Name" />
1010 }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public partial class CultureChooser
1616{
1717 [ Inject ]
1818 [ NotNull ]
19- private IOptionsMonitor < BootstrapBlazorOptions > ? BootstrapOptions { get ; set ; }
19+ private IOptions < BootstrapBlazorOptions > ? BootstrapOptions { get ; set ; }
2020
2121 [ Inject ]
2222 [ NotNull ]
Original file line number Diff line number Diff line change @@ -77,17 +77,11 @@ builder.Services.AddServerSideBlazor();
7777builder.Services.AddBootstrapBlazor();
7878
7979// @Localizer ["N26"]
80- builder.Services.AddRequestLocalization< ; IOptionsMonitor < ; BootstrapBlazorOptions> ;> ; ((localizerOption, blazorOption)=>
80+ builder.Services.AddRequestLocalization< ; IOptions < ; BootstrapBlazorOptions> ;> ; ((localizerOption, blazorOption)=>
8181{
82- blazorOption .OnChange (op => Invoke (op ));
83- Invoke (blazorOption .CurrentValue );
84-
85- void Invoke (BootstrapBlazorOptions option )
86- {
87- var supportedCultures = option .GetSupportedCultures ();
88- localizerOption .SupportedCultures = supportedCultures ;
89- localizerOption .SupportedUICultures = supportedCultures ;
90- }
82+ var supportedCultures = blazorOption .Value .GetSupportedCultures ();
83+ localizerOption .SupportedCultures = supportedCultures ;
84+ localizerOption .SupportedUICultures = supportedCultures ;
9185} );
9286
9387var app = builder.Build();
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ public partial class Dispatches
2222
2323 [ Inject ]
2424 [ NotNull ]
25- private IOptionsMonitor < BootstrapBlazorOptions > ? Options { get ; set ; }
25+ private IOptions < BootstrapBlazorOptions > ? Options { get ; set ; }
2626
2727 private async Task OnDispatch ( )
2828 {
@@ -36,7 +36,7 @@ private async Task OnDispatch()
3636 var clientInfo = await ClientService . GetClientInfo ( ) ;
3737 if ( clientInfo . Ip != null )
3838 {
39- var provider = IpLocatorFactory . Create ( Options . CurrentValue . IpLocatorOptions . ProviderName ) ;
39+ var provider = IpLocatorFactory . Create ( Options . Value . IpLocatorOptions . ProviderName ) ;
4040 var location = await provider . Locate ( clientInfo . Ip ) ;
4141 message = $ "{ message } { location } ";
4242 }
Original file line number Diff line number Diff line change @@ -22,18 +22,11 @@ public static IServiceCollection AddBootstrapBlazorServerService(this IServiceCo
2222 services . AddLogging ( logging => logging . AddFileLogger ( ) ) ;
2323
2424 // 增加多语言支持配置信息
25- services . AddRequestLocalization < IOptionsMonitor < BootstrapBlazorOptions > > ( ( localizerOption , blazorOption ) =>
25+ services . AddRequestLocalization < IOptions < BootstrapBlazorOptions > > ( ( localizerOption , blazorOption ) =>
2626 {
27- blazorOption . OnChange ( Invoke ) ;
28- Invoke ( blazorOption . CurrentValue ) ;
29- return ;
30-
31- void Invoke ( BootstrapBlazorOptions option )
32- {
33- var supportedCultures = option . GetSupportedCultures ( ) ;
34- localizerOption . SupportedCultures = supportedCultures ;
35- localizerOption . SupportedUICultures = supportedCultures ;
36- }
27+ var supportedCultures = blazorOption . Value . GetSupportedCultures ( ) ;
28+ localizerOption . SupportedCultures = supportedCultures ;
29+ localizerOption . SupportedUICultures = supportedCultures ;
3730 } ) ;
3831
3932 services . AddControllers ( ) ;
You can’t perform that action at this time.
0 commit comments