56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using System;
|
|
|
|
namespace MAX.Core.Helpers;
|
|
|
|
/// <summary>
|
|
/// 常用公共操作
|
|
/// </summary>
|
|
public static partial class Common
|
|
{
|
|
/// <summary>
|
|
/// 获取类型
|
|
/// </summary>
|
|
/// <typeparam name="T">类型</typeparam>
|
|
public static Type GetType<T>()
|
|
{
|
|
return GetType(typeof(T));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取类型
|
|
/// </summary>
|
|
/// <param name="type">类型</param>
|
|
public static Type GetType(Type type)
|
|
{
|
|
return Nullable.GetUnderlyingType(type) ?? type;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 换行符
|
|
/// </summary>
|
|
public static string Line => Environment.NewLine;
|
|
|
|
|
|
#if NET5_0
|
|
/// <summary>
|
|
/// 是否Linux操作系统
|
|
/// </summary>
|
|
public static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
|
|
|
/// <summary>
|
|
/// 是否Windows操作系统
|
|
/// </summary>
|
|
public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
|
|
|
/// <summary>
|
|
/// 是否苹果操作系统
|
|
/// </summary>
|
|
public static bool IsOsx => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
|
|
|
/// <summary>
|
|
/// 当前操作系统
|
|
/// </summary>
|
|
public static string System => IsWindows ? "Windows" : IsLinux ? "Linux" : IsOsx ? "OSX" : string.Empty;
|
|
#endif
|
|
}
|