-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTcpSocketExtensions.cs
More file actions
44 lines (38 loc) · 1.59 KB
/
TcpSocketExtensions.cs
File metadata and controls
44 lines (38 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System.Runtime.Versioning;
namespace BootstrapBlazor.TcpSocket;
/// <summary>
/// TcpSocket 扩展方法
/// </summary>
[UnsupportedOSPlatform("browser")]
public static class TcpSocketExtensions
{
/// <summary>
/// 增加 ITcpSocketFactory 服务
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddBootstrapBlazorTcpSocketFactory(this IServiceCollection services)
{
// 添加 ITcpSocketFactory 服务
services.AddSingleton<ITcpSocketFactory, DefaultTcpSocketFactory>();
// 增加 ISocketClientProvider 服务
services.TryAddTransient<ITcpSocketClientProvider, DefaultTcpSocketClientProvider>();
return services;
}
/// <summary>
/// 配置第三方数据模型与 <see cref="DataConverterCollections"/> 数据转换器集合配置扩展方法
/// </summary>
/// <param name="services"></param>
/// <param name="configureOptions"></param>
/// <returns></returns>
public static IServiceCollection ConfigureDataConverters(this IServiceCollection services, Action<DataConverterCollections> configureOptions)
{
services.Configure(configureOptions);
return services;
}
}