Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>9.0.8</Version>
<Version>9.0.10</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ public virtual bool TryConvertTo(ReadOnlyMemory<byte> data, [NotNullWhen(true)]
}
catch (Exception ex)
{
SocketLogging.LogError(ex, "DataConverter TryConvertTo failed");
SocketLogging.LogError(ex, $"DataConverter {nameof(TryConvertTo)} failed");
}

return ret;
}

Expand All @@ -64,8 +63,6 @@ protected virtual bool Parse(ReadOnlyMemory<byte> data, TEntity entity)
var ret = false;
if (entity != null)
{
var unuseProperties = new List<PropertyInfo>(32);

// 通过 SocketDataPropertyConverterAttribute 特性获取属性转换器
var properties = entity.GetType().GetProperties().Where(p => p.CanWrite).ToList();
foreach (var p in properties)
Expand All @@ -81,10 +78,8 @@ protected virtual bool Parse(ReadOnlyMemory<byte> data, TEntity entity)
}
}
}

ret = true;
}

return ret;
}

Expand All @@ -95,7 +90,6 @@ protected virtual bool Parse(ReadOnlyMemory<byte> data, TEntity entity)
{
attr = v;
}

return attr;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ static class DataPropertyExtensions
var type = attribute.Type;
if (type != null)
{
if (type == typeof(byte[]))
if (type == typeof(byte))
{
converter = new DataByteConverter();
}
else if (type == typeof(byte[]))
{
converter = new DataByteArrayConverter();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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/

namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 byte 转换器
Comment thread
ArgoZhang marked this conversation as resolved.
Outdated
/// </summary>
public class DataByteConverter : IDataPropertyConverter
{
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="data"></param>
public object? Convert(ReadOnlyMemory<byte> data)
{
Comment thread
ArgoZhang marked this conversation as resolved.
return data.Span[0];
}
}
1 change: 0 additions & 1 deletion test/UnitTestTcpSocket/TcpSocketFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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 BootstrapBlazor.Socket.Logging;
using Microsoft.Extensions.Logging;
using System.Buffers;
using System.Net;
Expand Down