Skip to content

Commit 58494cb

Browse files
committed
refactor: Lookup 服务示例改为异步
1 parent 06ed5f0 commit 58494cb

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/BootstrapBlazor.Server/Services/DemoLookupService.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,28 @@ namespace Microsoft.Extensions.DependencyInjection;
1010
/// </summary>
1111
internal class DemoLookupService(IServiceProvider provider) : LookupServiceBase
1212
{
13-
private IServiceProvider Provider { get; } = provider;
13+
/// <summary>
14+
/// <inheritdoc/>
15+
/// </summary>
16+
/// <param name="key"></param>
17+
/// <param name="data"></param>
18+
/// <returns></returns>
19+
public override IEnumerable<SelectedItem>? GetItemsByKey(string? key, object? data) => null;
1420

15-
public override IEnumerable<SelectedItem>? GetItemsByKey(string? key, object? data)
21+
/// <summary>
22+
/// <inheritdoc/>
23+
/// </summary>
24+
/// <param name="key"></param>
25+
/// <param name="data"></param>
26+
/// <returns></returns>
27+
public override async Task<IEnumerable<SelectedItem>?> GetItemsByKeyAsync(string? key, object? data)
1628
{
29+
await Task.Delay(1);
30+
1731
IEnumerable<SelectedItem>? items = null;
1832
if (key == "Foo.Complete")
1933
{
20-
var localizer = Provider.GetRequiredService<IStringLocalizer<Foo>>();
34+
var localizer = provider.GetRequiredService<IStringLocalizer<Foo>>();
2135
items = new List<SelectedItem>()
2236
{
2337
new() { Value = "True", Text = localizer["True"].Value },

0 commit comments

Comments
 (0)