Adding OSPlatform Processing

pull/5636/head
2dust 2024-08-27 19:44:50 +08:00
parent ae3ab15245
commit 54c16cad7d
3 changed files with 10 additions and 27 deletions

View File

@ -495,29 +495,6 @@ namespace ServiceLib.Common
#region 测速
/// <summary>
/// 取得本机 IP Address
/// </summary>
/// <returns></returns>
//public static List<string> GetHostIPAddress()
//{
// List<string> lstIPAddress = new List<string>();
// try
// {
// IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
// foreach (IPAddress ipa in IpEntry.AddressList)
// {
// if (ipa.AddressFamily == AddressFamily.InterNetwork)
// lstIPAddress.Add(ipa.ToString());
// }
// }
// catch (Exception ex)
// {
// SaveLog(ex.Message, ex);
// }
// return lstIPAddress;
//}
public static void SetSecurityProtocol(bool enableSecurityProtocolTls13)
{
if (enableSecurityProtocolTls13)
@ -708,7 +685,7 @@ namespace ServiceLib.Common
public static string GetExeName(string name)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (IsWindows())
{
return $"{name}.exe";
}
@ -718,6 +695,12 @@ namespace ServiceLib.Common
}
}
public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
public static bool IsOSX() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
#endregion 杂项
#region TempPath

View File

@ -54,7 +54,7 @@ namespace ServiceLib.Handler
public void AddProcess(IntPtr processHandle)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Utils.IsWindows())
{
_processJob ??= new();
_processJob?.AddProcess(processHandle);

View File

@ -444,7 +444,7 @@ namespace ServiceLib.Handler
private string? GetUrlFromCore(CoreInfo? coreInfo)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Utils.IsWindows())
{
return RuntimeInformation.ProcessArchitecture switch
{
@ -454,7 +454,7 @@ namespace ServiceLib.Handler
_ => null,
};
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
else if (Utils.IsLinux())
{
return RuntimeInformation.ProcessArchitecture switch
{