Skip to content

Commit 4665227

Browse files
committed
修改引用
1 parent fae1200 commit 4665227

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

src/BootstrapBlazor.Server/Components/Pages/Online.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public partial class Online : IDisposable
1818

1919
[Inject]
2020
[NotNull]
21-
private WebClientService? WebClientService { get; set; }
21+
private IWebClientService? WebClientService { get; set; }
2222

2323
private DynamicObjectContext? DataTableDynamicContext { get; set; }
2424

src/BootstrapBlazor.Server/Components/Samples/Client.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<p class="code-label">@((MarkupString)Localizer["BasicUsageP3"].Value)</p>
3131
<Pre>[Inject]
3232
[NotNull]
33-
private WebClientService? ClientService { get; set; }
33+
private IWebClientService? ClientService { get; set; }
3434

3535
private ClientInfo? ClientInfo { get; set; }
3636

src/BootstrapBlazor.Server/Components/Samples/Client.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public partial class Client
1212
{
1313
[Inject]
1414
[NotNull]
15-
private WebClientService? ClientService { get; set; }
15+
private IWebClientService? ClientService { get; set; }
1616

1717
private ClientInfo _clientInfo = new();
1818

src/BootstrapBlazor.Server/Components/Samples/Dispatches.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public partial class Dispatches
1414
{
1515
[Inject]
1616
[NotNull]
17-
private WebClientService? ClientService { get; set; }
17+
private IWebClientService? ClientService { get; set; }
1818

1919
[Inject]
2020
[NotNull]

src/BootstrapBlazor.Server/Components/Samples/Locators.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public partial class Locators
1616

1717
[Inject]
1818
[NotNull]
19-
WebClientService? ClientService { get; set; }
19+
IWebClientService? ClientService { get; set; }
2020

2121
[Inject]
2222
[NotNull]

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3808,7 +3808,7 @@
38083808
"BasicUsageP1": "Introduction to usage",
38093809
"BasicUsageP2": "1. The <code>UseBootstrapBlazor</code> middleware in the <b>Startup.cs</b> file that client information collection is performed.",
38103810
"BasicUsageTips": "<code>app.UseBootstrapBlazor</code> Middleware is located assembly <code>BootstrapBlazor.Middleware</code>, please refer to this package yourself for proper use",
3811-
"BasicUsageP3": "2. The component uses the injection service <code>WebClientService</code> to call the <code>GetClientInfo</code> method.",
3811+
"BasicUsageP3": "2. The component uses the injection service <code>IWebClientService</code> to call the <code>GetClientInfo</code> method.",
38123812
"BasicUsageP4": "3. Turn on IP geolocation",
38133813
"LocatorsProviderOptions": "<code>BootstrapBlazorOptions</code> section <code>WebClientOptions</code> By default it is <code>false</code>, which means the IP address location function is not enabled. Please change it to <code>true</code> in the configuration file or code.",
38143814
"LocatorsProviderDesc1": "Update the <code>appsetting.json</code> project configuration file",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3808,7 +3808,7 @@
38083808
"BasicUsageP1": "用法介绍",
38093809
"BasicUsageP2": "1. <b>Startup.cs</b> 文件中使用 <code>UseBootstrapBlazor</code> 中间件进行客户端信息收集",
38103810
"BasicUsageTips": "<code>app.UseBootstrapBlazor</code> 中间件位于程序集 <code>BootstrapBlazor.Middleware</code>,请自行引用此包才能正常使用",
3811-
"BasicUsageP3": "2. 组件中使用注入服务 <code>WebClientService</code> 调用 <code>GetClientInfo</code> 方法",
3811+
"BasicUsageP3": "2. 组件中使用注入服务 <code>IWebClientService</code> 调用 <code>GetClientInfo</code> 方法",
38123812
"BasicUsageP4": "3. 开启 IP 地理位置定位功能",
38133813
"LocatorsProviderOptions": "全局配置定位器选项 <code>WebClientOptions</code> 默认 <code>false</code> 没有启用 IP 地址定位功能,请在配置文件中或者代码中更改为 <code>true</code>",
38143814
"LocatorsProviderDesc1": "更新 <code>appsetting.json</code> 项目配置文件",

test/UnitTest/Services/ConnectionHubTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public async Task Callback_Ok()
2626
BeatInterval = TimeSpan.FromMilliseconds(200)
2727
};
2828

29-
var client = context.Services.GetRequiredService<WebClientService>();
29+
var client = context.Services.GetRequiredService<IWebClientService>();
3030
var service = context.Services.GetRequiredService<IConnectionService>();
3131
var cut = context.RenderComponent<ConnectionHub>();
3232
await cut.InvokeAsync(async () =>
@@ -60,7 +60,7 @@ await cut.InvokeAsync(async () =>
6060

6161
// 触发内部 ClientInfo 为空情况 覆盖 _clientInfo ??= new();
6262
options.Value.ConnectionHubOptions.Enable = false;
63-
client = context.Services.GetRequiredService<WebClientService>();
63+
client = context.Services.GetRequiredService<IWebClientService>();
6464
cut = context.RenderComponent<ConnectionHub>();
6565
await cut.InvokeAsync(async () =>
6666
{
@@ -71,7 +71,7 @@ await cut.InvokeAsync(async () =>
7171
// 设置 EnableIpLocator 为 false
7272
options.Value.ConnectionHubOptions.Enable = true;
7373
options.Value.ConnectionHubOptions.EnableIpLocator = false;
74-
client = context.Services.GetRequiredService<WebClientService>();
74+
client = context.Services.GetRequiredService<IWebClientService>();
7575
cut = context.RenderComponent<ConnectionHub>();
7676
await cut.InvokeAsync(async () =>
7777
{

test/UnitTest/Services/WebClientServiceTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async Task WebClientService_Ok()
2424
Engine = "engine",
2525
UserAgent = "test_agent"
2626
};
27-
var service = Context.Services.GetRequiredService<WebClientService>();
27+
var service = Context.Services.GetRequiredService<IWebClientService>();
2828
service.SetData(mockData);
2929
ClientInfo? client = null;
3030
_ = Task.Run(async () => client = await service.GetClientInfo());
@@ -53,15 +53,15 @@ public async Task WebClientOptions_Ok()
5353
var options = Context.Services.GetRequiredService<IOptionsMonitor<BootstrapBlazorOptions>>();
5454
options.CurrentValue.WebClientOptions.EnableIpLocator = true;
5555

56-
var service = Context.Services.GetRequiredService<WebClientService>();
56+
var service = Context.Services.GetRequiredService<IWebClientService>();
5757
var client = await service.GetClientInfo();
5858
Assert.Null(client.Ip);
5959
}
6060

6161
[Fact]
6262
public async Task GetClientInfo_Error()
6363
{
64-
var service = Context.Services.GetRequiredService<WebClientService>();
64+
var service = Context.Services.GetRequiredService<IWebClientService>();
6565
var client = await service.GetClientInfo();
6666

6767
// TimeoutException
@@ -75,7 +75,7 @@ public async Task GetClientInfo_Error()
7575
[Fact]
7676
public async Task SetData_Ok()
7777
{
78-
var service = Context.Services.GetRequiredService<WebClientService>();
78+
var service = Context.Services.GetRequiredService<IWebClientService>();
7979

8080
// 内部 ReturnTask 为空
8181
var fieldInfo = service.GetType().GetField("_taskCompletionSource", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
@@ -94,6 +94,6 @@ public async Task SetData_Ok()
9494
[Fact]
9595
public async Task WebClientService_Dispose()
9696
{
97-
await (Context.Services.GetRequiredService<WebClientService>() as IAsyncDisposable).DisposeAsync();
97+
await (Context.Services.GetRequiredService<IWebClientService>() as IAsyncDisposable).DisposeAsync();
9898
}
9999
}

0 commit comments

Comments
 (0)