2024-05-22 16:56:51 +09:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
2024-05-23 16:32:30 +09:00
|
|
|
|
namespace BitgetAPI.Utils
|
2024-05-22 16:56:51 +09:00
|
|
|
|
{
|
|
|
|
|
|
public static class Convertor
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get Enum Description
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="source"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string GetEnumDescription(Enum source)
|
|
|
|
|
|
{
|
|
|
|
|
|
FieldInfo fi = source.GetType().GetField(source.ToString());
|
|
|
|
|
|
var att = (DescriptionAttribute)fi.GetCustomAttribute(typeof(DescriptionAttribute));
|
|
|
|
|
|
if (att != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return att.Description;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return source.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static long GetDateTimeToUnixtimeStamp(DateTime datetime)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (long)(datetime - new DateTime(1970, 1, 1, 9, 0, 0)).TotalSeconds;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static DateTime GetUnixtimeStampToDateTime(long unixStamptime)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DateTime(1970, 1, 1, 9, 0, 0).AddMilliseconds(unixStamptime); ;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|