接口文件
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Hncore.Infrastructure.Extension
|
||||
{
|
||||
public static class NumberExtension
|
||||
{
|
||||
public static int ToInt(this int? num)
|
||||
{
|
||||
if (num == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Convert.ToInt32(num);
|
||||
}
|
||||
|
||||
public static int ToInt(this JToken obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int.TryParse(obj.ToString(), out var num);
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
public static decimal ToDecimal(this decimal? num)
|
||||
{
|
||||
if (num == null)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Convert.ToDecimal(num);
|
||||
}
|
||||
|
||||
public static long ToLong(this long? num)
|
||||
{
|
||||
if (num == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (long) num;
|
||||
}
|
||||
|
||||
public static int ToInt(this bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user