From d8d0d6429c0eedce937653c2360168a888cde338 Mon Sep 17 00:00:00 2001 From: argo-vip Date: Wed, 27 Aug 2025 11:11:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E7=B2=BE=E7=AE=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapBlazor.Socket/DataConverter/HexConverter.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs b/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs index 386027d4..9805709a 100644 --- a/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs +++ b/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs @@ -30,13 +30,7 @@ public static string ToString(byte[]? bytes, string? separator = "-") return BitConverter.ToString(bytes); } - var sb = new StringBuilder(bytes.Length * 3); - foreach (var b in bytes) - { - sb.Append(b.ToString("X2")); - sb.Append(separator); - } - return sb.ToString(0, sb.Length - 1); + return string.Join(separator, bytes.Select(i => Convert.ToString(i, 16))); } /// From 54a14e8da388d0997f8dcd1518c2c72e28560c2b Mon Sep 17 00:00:00 2001 From: argo-vip Date: Wed, 27 Aug 2025 11:11:18 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs b/src/extensions/BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs index 76b1e143..bcd0fb24 100644 --- a/src/extensions/BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs +++ b/src/extensions/BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs @@ -19,7 +19,7 @@ static class DataPropertyExtensions { var converterParameters = attribute.ConverterParameters; var c = Activator.CreateInstance(converterType, converterParameters); - if(c is IDataPropertyConverter v) + if (c is IDataPropertyConverter v) { converter = v; } From cf874f06d7b63078ec007702702a8df1c96e434c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 27 Aug 2025 11:22:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20upper=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=94=AF=E6=8C=81=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapBlazor.Socket/DataConverter/HexConverter.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs b/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs index 9805709a..e8e2e28e 100644 --- a/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs +++ b/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs @@ -2,8 +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 System.Text; - namespace BootstrapBlazor.Components.DataConverter; /// @@ -17,8 +15,9 @@ public static class HexConverter /// /// The byte array to convert. /// + /// /// A string containing the hexadecimal representation of the byte array. - public static string ToString(byte[]? bytes, string? separator = "-") + public static string ToString(byte[]? bytes, string? separator = "-", bool upper = true) { if (bytes == null || bytes.Length == 0) { @@ -30,7 +29,7 @@ public static string ToString(byte[]? bytes, string? separator = "-") return BitConverter.ToString(bytes); } - return string.Join(separator, bytes.Select(i => Convert.ToString(i, 16))); + return string.Join(separator, bytes.Select(i => upper ? i.ToString("X2") : i.ToString("x2"))); } ///