取消区域性设置

This commit is contained in:
zqm
2025-12-12 15:40:43 +08:00
parent 6a4f7d5a71
commit cbd69c92b2
3 changed files with 3 additions and 117 deletions

View File

@@ -12,7 +12,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyProduct("com.joyd.Utils")] [assembly: AssemblyProduct("com.joyd.Utils")]
[assembly: AssemblyCopyright("Copyright © 2025 JoyD")] [assembly: AssemblyCopyright("Copyright © 2025 JoyD")]
[assembly: AssemblyTrademark("JoyD")] [assembly: AssemblyTrademark("JoyD")]
[assembly: AssemblyCulture("zh-CN")] [assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型 // 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型

View File

@@ -156,119 +156,5 @@ namespace JoyD.Windows.CS
{ {
return Convert.FromBase64String(base64); return Convert.FromBase64String(base64);
} }
/// <summary>
/// 构建不含前缀的FTPC命令字节流
/// </summary>
/// <param name="command">命令字符ASCII编码</param>
/// <param name="parameters">命令参数,支持以下类型:
/// <list type="bullet">
/// <item><description>long: 24位大端序数据如filesize24或addr24</description></item>
/// <item><description>ushort: 16位大端序数据长度</description></item>
/// <item><description>uint: 32位大端序数据如CRC32值</description></item>
/// <item><description>string: ASCII编码的字符串参数</description></item>
/// <item><description>byte[]: 原始字节数组参数</description></item>
/// </list>
/// </param>
/// <returns>包含命令、参数和CRC16校验的完整字节数组</returns>
/// <exception cref="ArgumentException">当参数类型不支持时抛出</exception>
public static byte[] BuildRawFTPCommand(char command, params object[] parameters)
{
using (MemoryStream ms = new MemoryStream())
{
// 写入命令ASCII编码的单个字符
ms.WriteByte((byte)command);
// 添加参数(参数之间没有间隔,直接写入字节)
foreach (var param in parameters)
{
if (param is long)
{
// filesize24或addr24: 3字节大端序
long value = (long)param;
// 使用位运算直接获取24位值的三个字节大端序
byte byte1 = (byte)((value >> 16) & 0xFF); // 最高位字节
byte byte2 = (byte)((value >> 8) & 0xFF); // 中间字节
byte byte3 = (byte)(value & 0xFF); // 最低位字节
// 直接写入三个字节
ms.WriteByte(byte1);
ms.WriteByte(byte2);
ms.WriteByte(byte3);
}
else if (param is ushort)
{
// N16: 16位大端序数据长度
ushort value = (ushort)param;
// 使用位运算直接获取16位值的两个字节大端序
byte byte1 = (byte)((value >> 8) & 0xFF); // 高8位字节
byte byte2 = (byte)(value & 0xFF); // 低8位字节
// 直接写入两个字节
ms.WriteByte(byte1);
ms.WriteByte(byte2);
}
else if (param is uint)
{
// 处理uint类型如CRC32值
uint value = (uint)param;
// 使用位运算直接获取32位值的四个字节大端序
byte byte1 = (byte)((value >> 24) & 0xFF); // 最高位字节
byte byte2 = (byte)((value >> 16) & 0xFF); // 次高位字节
byte byte3 = (byte)((value >> 8) & 0xFF); // 次低位字节
byte byte4 = (byte)(value & 0xFF); // 最低位字节
// 直接写入四个字节
ms.WriteByte(byte1);
ms.WriteByte(byte2);
ms.WriteByte(byte3);
ms.WriteByte(byte4);
}
else if (param is string)
{
// 字符串参数直接写入ASCII字节
string strValue = (string)param;
byte[] strBytes = Encoding.ASCII.GetBytes(strValue);
ms.Write(strBytes, 0, strBytes.Length);
}
else if (param is byte[])
{
// byte[]参数直接写入
byte[] data = (byte[])param;
ms.Write(data, 0, data.Length);
}
}
// 获取当前流中的所有字节用于计算CRC16
byte[] currentBytes = ms.ToArray();
// 计算CRC16
ushort crc16 = CalculateCRC16(currentBytes, 0, currentBytes.Length);
// 写入CRC16大端序
byte crcByte1 = (byte)((crc16 >> 8) & 0xFF); // 高8位
byte crcByte2 = (byte)(crc16 & 0xFF); // 低8位
ms.WriteByte(crcByte1);
ms.WriteByte(crcByte2);
// 返回完整的字节数组
return ms.ToArray();
}
}
/// <summary>
/// 构建完整的通信命令字符串
/// </summary>
/// <param name="rawFTPCommand">通过BuildRawFTPCommand方法构建的原始FTPC命令字节流</param>
/// <returns>完整的通信命令字符串格式为set(LFMGR: FTPC, "base64_encoded_command")</returns>
/// <exception cref="ArgumentNullException">当输入命令字节流为null时抛出</exception>
public static string BuildCommunicationCommand(byte[] rawFTPCommand)
{
string base64 = Convert.ToBase64String(rawFTPCommand);
return $"set(LFMGR: FTPC, \"{base64}\")";
}
} }
} }

View File

@@ -10,7 +10,7 @@ $targetDllName = "JoyD.Windows.CS.Utils.dll" # 保持与AssemblyName一致
# NuGet包元数据配置 - 在此处修改所有元数据 # NuGet包元数据配置 - 在此处修改所有元数据
$packageId = "com.joyd.utils" $packageId = "com.joyd.utils"
$version = "1.0.0.0" # 更新版本号以确保用户安装的是修复后的版本 $version = "1.0.0.2" # 更新版本号以确保用户安装的是修复后的版本
$title = "通用工具库" $title = "通用工具库"
$authors = "曾庆明" $authors = "曾庆明"
$owners = "JoyD Technology" $owners = "JoyD Technology"
@@ -22,7 +22,7 @@ $licenseUrl = "https://opensource.org/licenses/MIT"
$iconFileName = "Utils.ico" $iconFileName = "Utils.ico"
$iconSourcePath = Join-Path $scriptDir $iconFileName $iconSourcePath = Join-Path $scriptDir $iconFileName
$iconUrl = "http://47.111.181.23:8081/repository/gradle/main/Utils.ico" $iconUrl = "http://47.111.181.23:8081/repository/gradle/main/Utils.ico"
$releaseNotes = "初始版本发布" $releaseNotes = "取消区域性设置,默认使用 invariant culture"
# 其他设置 # 其他设置
$nupkgFileName = "$packageId.$version.nupkg" $nupkgFileName = "$packageId.$version.nupkg"