Skip to content

Commit 2aba6f8

Browse files
authored
doc(TcpSocket): remove DataTypeConverterAttribute class doc (#6743)
* chore: bump version 9.0.1 * doc: 移除 DataTypeConverter 标签文档
1 parent faec42f commit 2aba6f8

File tree

5 files changed

+9
-24
lines changed

5 files changed

+9
-24
lines changed

src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<PackageReference Include="BootstrapBlazor.WinBox" Version="9.0.7" />
8383
<PackageReference Include="Longbow.Logging" Version="9.0.1" />
8484
<PackageReference Include="Longbow.Modbus" Version="9.0.4" />
85-
<PackageReference Include="Longbow.Sockets" Version="9.0.0" />
85+
<PackageReference Include="Longbow.Sockets" Version="9.0.1" />
8686
<PackageReference Include="Longbow.Tasks" Version="9.0.2" />
8787
<PackageReference Include="Longbow.TcpSocket" Version="9.0.7" />
8888
</ItemGroup>

src/BootstrapBlazor.Server/Components/Samples/Sockets/DataEntities.razor

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77
<DemoBlock Title="@Localizer["NormalTitle"]"
88
Introduction="@Localizer["NormalIntro"]"
99
Name="Normal" ShowCode="false">
10-
<p>
11-
通过 <code>DataTypeConverterAttribute</code> 类标签与 <code>DataPropertyConverterAttribute</code>
12-
属性标签可以将通讯数据自动转化为我们系统中需要的业务实体类,示例如下:</p>
13-
<Pre>[DataTypeConverter(Type = typeof(DataConverter&lt;MockEntity&gt;))]
14-
class MockEntity
10+
<p>通过 <code>DataPropertyConverterAttribute</code> 属性标签可以将通讯数据自动转化为我们系统中需要的业务实体类,示例如下:</p>
11+
<Pre>class MockEntity
1512
{
1613
[DataPropertyConverter(Type = typeof(byte[]), Offset = 0, Length = 5)]
1714
public byte[]? Header { get; set; }
@@ -25,12 +22,7 @@ class MockEntity
2522
[DataPropertyConverter(Type = typeof(int), Offset = 8, Length = 1)]
2623
public int Value2 { get; set; }
2724
}</Pre>
28-
<p class="code-label">1. <code>DataTypeConverter</code> 参数说明:</p>
29-
<ul class="ul-demo">
30-
<li><b>Type</b>: 自定义转换器类型,组件库内置了 <code>DataConverter</code> 泛型类,建议看一下源码非常方便扩展出自己的转换器
31-
</li>
32-
</ul>
33-
<p class="code-label">2. <code>DataPropertyConverterAttribute</code> 参数说明</p>
25+
<p class="code-label">1. <code>DataPropertyConverterAttribute</code> 参数说明</p>
3426
<ul class="ul-demo">
3527
<li><b>Type</b>: 转换目标数据类型</li>
3628
<li><b>Offset</b>: 数据偏移量,即在接收到的数据中起始位置</li>
@@ -64,8 +56,7 @@ class MockEntity
6456
<li><code>DataUInt64LittleEndianConverter</code> 转成 ulong 无符号整形小端读取</li>
6557
</ul>
6658
<p>自定义数据类型转化器示例</p>
67-
<Pre>[DataTypeConverter(Type = typeof(DataConverter&lt;MockEntity&gt;))]
68-
class MockEntity
59+
<Pre>class MockEntity
6960
{
7061
[DataPropertyConverter(Type = typeof(byte[]), Offset = 0, Length = 5)]
7162
public byte[]? Header { get; set; }
@@ -109,20 +100,17 @@ if (attr is { Type: not null })
109100
}</Pre>
110101
<Pre>service.ConfigureDataConverters(options =>
111102
{
112-
// 配置 MockEntity 转换
113-
options.AddTypeConverter&lt;MockEntity&gt;();
114-
115103
// 配置 MockEntity 属性 Header 转换逻辑 从起始位置 0 开始读取 5 个字节
116104
options.AddPropertyConverter&lt;MockEntity&gt;(entity => entity.Header, new DataPropertyConverterAttribute()
117105
{
118106
Offset = 0,
119-
Length = 5
107+
Length = 2
120108
});
121109

122110
// 配置 MockEntity 属性 Body 转换逻辑 从起始位置 5 开始读取 2 个字节
123111
options.AddPropertyConverter&lt;MockEntity&gt;(entity => entity.Body, new DataPropertyConverterAttribute()
124112
{
125-
Offset = 5,
113+
Offset = 3,
126114
Length = 2
127115
});
128116
});</Pre>

src/BootstrapBlazor.Server/Components/Samples/Sockets/SocketFactories.razor

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ private async Task CreateClient()
9292
<p>数据适配器设计思路如下</p>
9393

9494
<ol class="ul-demo">
95-
<li>使用 <code>DataTypeConverterAttribute</code> 标签约定通讯数据使用那个转换类型进行转换 指定类型需继承 <code>IDataConverter</code>
96-
接口
97-
</li>
9895
<li>使用 <code>DataPropertyConverterAttribute</code> 标签约定如何转换数据类型 (Property) 属性值</li>
9996
</ol>
10097

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7168,7 +7168,7 @@
71687168
"DataEntityTitle": "Socket Auto Entity",
71697169
"DataEntityDescription": "After receiving the communication data, it is automatically converted into the entity class required by the business",
71707170
"NormalTitle": "Basic usage",
7171-
"NormalIntro": "Enable automatic data conversion through the <code>DataTypeConverterAttribute</code> attribute",
7171+
"NormalIntro": "Enable automatic data conversion through the <code>DataPropertyConverterAttribute</code> attribute",
71727172
"ConfigTitle": "DataType Converter",
71737173
"ConfigIntro": "Use the <code>ConfigureDataConverters</code> method to map the entity class and automatically convert the received data"
71747174
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7168,7 +7168,7 @@
71687168
"DataEntityTitle": "Socket 数据转化实体类",
71697169
"DataEntityDescription": "接收到通讯数据后自动转成业务需要的实体类",
71707170
"NormalTitle": "基本用法",
7171-
"NormalIntro": "通过 <code>DataTypeConverterAttribute</code> 标签开启数据自动转换功能",
7171+
"NormalIntro": "通过 <code>DataPropertyConverterAttribute</code> 标签开启数据自动转换功能",
71727172
"ConfigTitle": "数据实体类映射配置",
71737173
"ConfigIntro": "使用 <code>ConfigureDataConverters</code> 方法对实体类进行映射配置将接收到的数据自动转化"
71747174
},

0 commit comments

Comments
 (0)