瀏覽代碼

1. 新增HEX扩展转换
2. 版本更新

Shun 2 年之前
父節點
當前提交
196ec54184

+ 2 - 2
src/YSAI.AllenBradley/YSAI.AllenBradley.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -16,6 +16,6 @@
     <Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
   </PropertyGroup>
   <ItemGroup>
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Beckhoff/YSAI.Beckhoff.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -17,7 +17,7 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="Beckhoff.TwinCAT.Ads" Version="6.1.86" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
   <!--<ItemGroup>
     <ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />

+ 2 - 2
src/YSAI.Can/YSAI.Can.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -16,7 +16,7 @@
     <Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
   </PropertyGroup>
   <ItemGroup>
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="Kvaser.CanLib">

+ 2 - 2
src/YSAI.Core/YSAI.Core.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.24534</Version>
+    <Version>23.327.26637</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -19,6 +19,6 @@
     <PackageReference Include="Microsoft.ClearScript" Version="7.4.4" />
     <PackageReference Include="System.IO.Ports" Version="8.0.0" />
     <PackageReference Include="YSAI.Log" Version="23.319.17368" />
-    <PackageReference Include="YSAI.Unility" Version="23.327.24298" />
+    <PackageReference Include="YSAI.Unility" Version="23.327.26405" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.DB/YSAI.DB.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -21,7 +21,7 @@
     <PackageReference Include="System.Data.OracleClient" Version="1.0.8" />
     <PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
     <PackageReference Include="System.Data.SQLite" Version="1.0.118" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
   <!--<ItemGroup>
 		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />

+ 1 - 1
src/YSAI.DaqManage/YSAI.DaqManage.csproj

@@ -7,7 +7,7 @@
   </PropertyGroup>
 	<ItemGroup>
 		<FrameworkReference Include="Microsoft.AspNetCore.App" />
-		<PackageReference Include="YSAI.Core" Version="23.327.23613" />
+		<PackageReference Include="YSAI.Core" Version="23.327.26637" />
 	</ItemGroup>
 
 	<!--<ItemGroup>

+ 2 - 2
src/YSAI.Kafka/YSAI.Kafka.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -17,7 +17,7 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="Confluent.Kafka" Version="2.3.0" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
   <!--<ItemGroup>
 		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />

+ 2 - 2
src/YSAI.Mewtocol/YSAI.Mewtocol.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -17,6 +17,6 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="Mewtocol.NET" Version="0.8.1" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Mitsubishi/YSAI.Mitsubishi.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -16,6 +16,6 @@
     <Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
   </PropertyGroup>
   <ItemGroup>
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Modbus/YSAI.Modbus.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -18,7 +18,7 @@
   <ItemGroup>
     <PackageReference Include="NModbus" Version="3.0.81" />
     <PackageReference Include="NModbus.Serial" Version="3.0.81" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
   <!--<ItemGroup>
 		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />

+ 2 - 2
src/YSAI.Mqtt/YSAI.Mqtt.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -18,7 +18,7 @@
   <ItemGroup>
     <PackageReference Include="MQTTnet" Version="4.3.1.873" />
     <PackageReference Include="MQTTnet.AspNetCore" Version="4.3.1.873" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
   <!--<ItemGroup>
 		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />

+ 2 - 2
src/YSAI.NetMQ/YSAI.NetMQ.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -18,6 +18,6 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="NetMQ" Version="4.0.1.13" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Netty/YSAI.Netty.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -18,6 +18,6 @@
   <ItemGroup>
     <PackageReference Include="DotNetty.Handlers" Version="0.7.5" />
     <PackageReference Include="DotNetty.Transport" Version="0.7.5" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Omron/YSAI.Omron.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -16,6 +16,6 @@
     <Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
   </PropertyGroup>
   <ItemGroup>
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Opc/YSAI.Opc.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -21,7 +21,7 @@
   </ItemGroup>
   <ItemGroup>
     <PackageReference Include="OPCFoundation.NetStandard.Opc.Ua" Version="1.4.372.76" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
   <!--<ItemGroup>
 		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />

+ 2 - 2
src/YSAI.RabbitMQ/YSAI.RabbitMQ.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -17,7 +17,7 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="RabbitMQ.Client" Version="6.7.0" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
   <!--<ItemGroup>
 		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />

+ 2 - 2
src/YSAI.Redis/YSAI.Redis.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -17,6 +17,6 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="StackExchange.Redis" Version="2.7.4" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
 </Project>

+ 1 - 1
src/YSAI.RelayManage/YSAI.RelayManage.csproj

@@ -9,7 +9,7 @@
 	<ItemGroup>
 		<PackageReference Include="RabbitMQ.Client" Version="6.7.0" />
 		<PackageReference Include="Confluent.Kafka" Version="2.3.0" />
-		<PackageReference Include="YSAI.Core" Version="23.327.23613" />
+		<PackageReference Include="YSAI.Core" Version="23.327.26637" />
 		<FrameworkReference Include="Microsoft.AspNetCore.App" />
 	</ItemGroup>
 

+ 2 - 2
src/YSAI.Rpc/YSAI.Rpc.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -19,6 +19,6 @@
     <PackageReference Include="DotNetty.Codecs" Version="0.7.5" />
     <PackageReference Include="ImpromptuInterface" Version="8.0.4" />
     <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Siemens/YSAI.Siemens.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.23943</Version>
+    <Version>23.327.25040</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -17,7 +17,7 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="S7netplus" Version="0.20.0" />
-    <PackageReference Include="YSAI.Core" Version="23.327.23613" />
+    <PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
   <!--<ItemGroup>
 		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />

+ 1 - 1
src/YSAI.Test/YSAI.Test.csproj

@@ -17,7 +17,7 @@
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
     </PackageReference>
-	<PackageReference Include="YSAI.Core" Version="23.327.23613" />
+	<PackageReference Include="YSAI.Core" Version="23.327.26637" />
   </ItemGroup>
 
   <ItemGroup>

+ 0 - 41
src/YSAI.Unility/ByteTool.cs

@@ -473,16 +473,6 @@ namespace YSAI.Unility
             return string.Join(" ", data.Select(t => t.ToString("X2")));
         }
 
-        /// <summary>
-        /// 字节数组转16进制字符
-        /// </summary>
-        /// <param name="byteArray"></param>
-        /// <returns></returns>
-        public static string ByteArrayToString(this byte[] byteArray)
-        {
-            return string.Join(" ", byteArray.Select(t => t.ToString("X2")));
-        }
-
         /// <summary>
         /// 16进制字符串转字节数组
         /// </summary>
@@ -511,38 +501,7 @@ namespace YSAI.Unility
             }
         }
 
-        /// <summary>
-        /// Asciis字符串数组字符串装字节数组
-        /// </summary>
-        /// <param name="str"></param>
-        /// <param name="strict"></param>
-        /// <returns></returns>
-        public static byte[] AsciiStringToByteArray(this string str, bool strict = true)
-        {
-            if (string.IsNullOrWhiteSpace(str) || str.Trim().Replace(" ", "").Length % 2 != 0)
-                throw new ArgumentException("请传入有效的参数");
 
-            if (strict)
-            {
-                List<string> stringList = new List<string>();
-                foreach (var item in str.Split(' '))
-                {
-                    stringList.Add(((char)Convert.ToByte(item, 16)).ToString());
-                }
-                return string.Join("", stringList).StringToByteArray(false);
-            }
-            else
-            {
-                str = str.Trim().Replace(" ", "");
-                var stringList = new List<string>();
-                for (int i = 0; i < str.Length; i++)
-                {
-                    var stringAscii = str[i].ToString() + str[++i].ToString();
-                    stringList.Add(((char)Convert.ToByte(stringAscii, 16)).ToString());
-                }
-                return string.Join("", stringList).StringToByteArray(false);
-            }
-        }
 
         /// <summary>
         /// Asciis数组字符串装字节数组

+ 42 - 271
src/YSAI.Unility/ExtensionTool.cs

@@ -1,5 +1,4 @@
 using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
 using System.Diagnostics;
 using System.Net;
 using System.Security.Cryptography;
@@ -71,45 +70,7 @@ namespace YSAI.Unility
             return OR;
         }
 
-        /// <summary>
-        /// 判断为空GUID
-        /// </summary>
-        /// <param name="guid"></param>
-        /// <returns></returns>
-        public static bool IsEmptyGuid(this Guid guid)
-        {
-            return guid == Guid.Empty;
-        }
-
-        /// <summary>
-        /// 判断为空GUID
-        /// </summary>
-        /// <param name="guid"></param>
-        /// <returns></returns>
-        public static bool IsEmptyGuid(this Guid? guid)
-        {
-            return !guid.HasValue || guid.Value == Guid.Empty;
-        }
 
-        /// <summary>
-        /// 判断不为空GUID
-        /// </summary>
-        /// <param name="guid"></param>
-        /// <returns></returns>
-        public static bool IsNotEmptyGuid(this Guid guid)
-        {
-            return guid != Guid.Empty;
-        }
-
-        /// <summary>
-        /// 判断不为NULL和空GUID
-        /// </summary>
-        /// <param name="guid"></param>
-        /// <returns></returns>
-        public static bool IsNotEmptyGuid(this Guid? guid)
-        {
-            return guid.HasValue && guid.Value != Guid.Empty;
-        }
 
         /// <summary>
         /// 将GUID转换为整数
@@ -290,25 +251,7 @@ namespace YSAI.Unility
             return date.ToString("yyyy-MM-dd HH:mm:ss.fff").ToDateTime();
         }
 
-        /// <summary>
-        /// 判断字符串是否为null或""
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsNullOrEmpty(this string str)
-        {
-            return string.IsNullOrEmpty(str);
-        }
 
-        /// <summary>
-        /// 判断字符串是否为null或""或" "(包含空字符的字符串)
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsNullOrWhiteSpace(this string str)
-        {
-            return string.IsNullOrWhiteSpace(str);
-        }
 
         /// <summary>
         /// 比较字符串区分大小写
@@ -352,55 +295,7 @@ namespace YSAI.Unility
             return Guid.TryParse(str.Trim1(), out Guid guid) ? guid : Guid.Empty;
         }
 
-        /// <summary>
-        /// 判断一个字符串是否是GUID
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsGuid(this string str)
-        {
-            return Guid.TryParse(str.Trim1(), out _);
-        }
 
-        /// <summary>
-        /// 判断一个字符串是否是GUID
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsGuid(this string str, out Guid guid)
-        {
-            return Guid.TryParse(str.Trim1(), out guid);
-        }
-
-        /// <summary>
-        /// 判断一个字符串是否是字体图标(以fa开头)
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsFontIco(this string str)
-        {
-            return str.Trim1().StartsWith("fa");
-        }
-
-        /// <summary>
-        /// 判断字符串是否为整数
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsInt(this string str)
-        {
-            return int.TryParse(str, out _);
-        }
-
-        /// <summary>
-        /// 判断字符串是否为整数
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsInt(this string str, out int i)
-        {
-            return int.TryParse(str, out i);
-        }
 
         /// <summary>
         /// 将字符串转换为整数
@@ -413,25 +308,7 @@ namespace YSAI.Unility
             return int.TryParse(str, out int i) ? i : defaultValue;
         }
 
-        /// <summary>
-        /// 判断字符串是否是长整型
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsLong(this string str)
-        {
-            return long.TryParse(str, out _);
-        }
 
-        /// <summary>
-        /// 判断字符串是否是长整型
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsLong(this string str, out long l)
-        {
-            return long.TryParse(str, out l);
-        }
 
         /// <summary>
         /// 将字符串转换为长整型
@@ -444,25 +321,7 @@ namespace YSAI.Unility
             return long.TryParse(str, out long l) ? l : defauleValue;
         }
 
-        /// <summary>
-        /// 判断字符串是否为数字
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsDecimal(this string str)
-        {
-            return decimal.TryParse(str, out _);
-        }
 
-        /// <summary>
-        /// 判断字符串是否为数字
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsDecimal(this string str, out decimal d)
-        {
-            return decimal.TryParse(str, out d);
-        }
 
         /// <summary>
         /// 将字符串转换为数字
@@ -475,25 +334,7 @@ namespace YSAI.Unility
             return decimal.TryParse(str, out decimal d) ? d : defaultValue;
         }
 
-        /// <summary>
-        /// 判断字符串是否为日期时间
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsDateTime(this string str)
-        {
-            return DateTime.TryParse(str, out DateTime dt);
-        }
 
-        /// <summary>
-        /// 判断字符串是否为日期时间
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsDateTime(this string str, out DateTime dt)
-        {
-            return DateTime.TryParse(str, out dt);
-        }
 
         /// <summary>
         /// 将字符串转换为日期时间
@@ -505,33 +346,7 @@ namespace YSAI.Unility
             return DateTime.TryParse(str, out DateTime dt) ? dt : DateTime.MinValue;
         }
 
-        /// <summary>
-        /// 验证字符串是否为数字
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsDigital(this string str)
-        {
-            foreach (char c in str.ToCharArray())
-            {
-                if (!char.IsDigit(c))
-                {
-                    return false;
-                }
-            }
-            return true;
-        }
 
-        /// <summary>
-        /// 验证是否为固话号码
-        /// </summary>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        public static bool IsTelNumber(this string str)
-        {
-            //去掉-线后全为数字
-            return str.IsNullOrWhiteSpace() ? false : !str.StartsWith("-") && str.Replace("-", "").IsDigital();
-        }
 
         /// <summary>
         /// 移出所有空格
@@ -1249,75 +1064,14 @@ namespace YSAI.Unility
 
 
 
-        /// <summary>
-        /// 是不是为空
-        /// </summary>
-        /// <param name="value">字符串</param>
-        /// <returns></returns>
-        public static bool IsEmpty(this string value)
-        {
-            return string.IsNullOrWhiteSpace(value);
-        }
-
-        public static bool IsNull(this string value)
-        {
-            return value == null;
-        }
-
-        public static bool IsEmpty(this Guid? value)
-        {
-            if (!value.HasValue)
-            {
-                return true;
-            }
-            return value.Value.IsEmpty();
-        }
-
-        public static bool IsEmpty(this Guid value)
-        {
-            if (value == Guid.Empty)
-            {
-                return true;
-            }
-            return false;
-        }
 
-        public static bool IsEmpty(this DateTime? value)
-        {
-            if (!value.HasValue)
-            {
-                return true;
-            }
-            return value.Value.IsEmpty();
-        }
-
-        public static bool IsEmpty(this DateTime value)
-        {
-            if (value == DateTime.MinValue)
-            {
-                return true;
-            }
-            return false;
-        }
-
-        public static bool IsEmpty(this object value)
-        {
-            if (value != null && !string.IsNullOrEmpty(value.ToString()))
-            {
-                return false;
-            }
-            return true;
-        }
 
         public static T SafeValue<T>(this T? value) where T : struct
         {
             return value.GetValueOrDefault();
         }
 
-        public static bool IsNum(this string value)
-        {
-            return Regex.IsMatch(value, "^\\d+(\\.\\d*)?$");
-        }
+
 
         /// <summary>
         /// 读取Json文件内容为集合
@@ -1492,30 +1246,7 @@ namespace YSAI.Unility
             return value;
         }
 
-        /// <summary>
-        /// 判断是不是有效JSON
-        /// </summary>
-        /// <param name="json">Json 字符串</param>
-        /// <returns></returns>
-        public static bool IsJson(this string json)
-        {
-            try
-            {
-                JToken jToken = JToken.Parse(json);
-                if (jToken.Type != JTokenType.Object)
-                {
-                    return false;
-                }
-                else
-                {
-                    return true;
-                }
-            }
-            catch
-            {
-                return false;
-            }
-        }
+
 
         /// <summary>
         /// JSON格式化
@@ -1546,5 +1277,45 @@ namespace YSAI.Unility
                 return str;
             }
         }
+
+
+        /// <summary>
+        /// 字节数组转16进制字符
+        /// </summary>
+        /// <param name="bytes">字节数组</param>
+        /// <returns></returns>
+        public static string ToHexString(this byte[] bytes)
+        {
+            return string.Join(" ", bytes.Select(t => t.ToString("X2")));
+        }
+
+
+        /// <summary>
+        /// 16进制字符串转字节数组
+        /// </summary>
+        /// <param name="str">字符串</param>
+        /// <param name="strict">严格模式(严格按两个字母间隔一个空格)</param>
+        /// <returns></returns>
+        public static byte[] ToHex(this string str, bool strict = true)
+        {
+            if (string.IsNullOrWhiteSpace(str) || str.Trim().Replace(" ", "").Length % 2 != 0)
+                throw new ArgumentException("请传入有效的参数");
+
+            if (strict)
+            {
+                return str.Split(' ').Where(t => t?.Length == 2).Select(t => Convert.ToByte(t, 16)).ToArray();
+            }
+            else
+            {
+                str = str.Trim().Replace(" ", "");
+                var list = new List<byte>();
+                for (int i = 0; i < str.Length; i++)
+                {
+                    var string16 = str[i].ToString() + str[++i].ToString();
+                    list.Add(Convert.ToByte(string16, 16));
+                }
+                return list.ToArray();
+            }
+        }
     }
 }

文件差異過大導致無法顯示
+ 320 - 58
src/YSAI.Unility/ValidatorTool.cs


+ 1 - 1
src/YSAI.Unility/YSAI.Unility.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.327.24298</Version>
+    <Version>23.327.26405</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>

+ 1 - 1
src/YSAI.VT/Program.cs

@@ -15,7 +15,7 @@ namespace YSAI.VT
             List<string> strings = new List<string>
             {
 #if RELEASE
-                "YSAI.Core",
+                //"YSAI.Core",
                 //"YSAI.Log",
                 //"YSAI.Unility",
                 //"YSAI.AllenBradley",