Skip to content

Commit ac16edb

Browse files
committed
doc: 更新配置转换器集合文档
1 parent e822300 commit ac16edb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,22 @@ class MockEntity
110110
return new Foo() { Id = data.Span[0], Name = name };
111111
}
112112
}</Pre>
113+
114+
<p class="code-label">针对第三方程序集的数据类型解决方案如下:</p>
115+
<p>使用 <code></code></p>
116+
117+
<Pre>builder.Services.ConfigureSocketDataConverters(options =>
118+
{
119+
options.AddTypeConverter&lt;MockEntity&gt;();
120+
options.AddPropertyConverter&lt;MockEntity&gt;(entity =&gt; entity.Header, new SocketDataPropertyConverterAttribute()
121+
{
122+
Offset = 0,
123+
Length = 5
124+
});
125+
options.AddPropertyConverter&lt;MockEntity&gt;(entity =&gt; entity.Body, new SocketDataPropertyConverterAttribute()
126+
{
127+
Offset = 5,
128+
Length = 2
129+
});
130+
});
131+
</Pre>

0 commit comments

Comments
 (0)