增加老版本 KJDWebService
This commit is contained in:
1 parent
58abbb5b4f
commit
f84c4c1949
115 files changed
+36598
-18
No files matched your search
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using NaiBa.Util.Helper;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace NaiBa.Util.Extension
|
||||
{
|
||||
public static partial class Extensions
|
||||
{
|
||||
public static bool IsNullOrEmpty(this object value)
|
||||
{
|
||||
if (value != null && !string.IsNullOrEmpty(value.ParseToString()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsNullOrZero(this object value)
|
||||
{
|
||||
if (value == null || string.IsNullOrEmpty(value.ParseToString()) || value.ParseToString().Trim() == "0")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsNumericType(this object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (Type.GetTypeCode(value.GetType()))
|
||||
{
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.SByte:
|
||||
case TypeCode.UInt16:
|
||||
case TypeCode.UInt32:
|
||||
case TypeCode.UInt64:
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.Int64:
|
||||
case TypeCode.Decimal:
|
||||
case TypeCode.Double:
|
||||
case TypeCode.Single:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsStringType(this object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (Type.GetTypeCode(value.GetType()))
|
||||
{
|
||||
case TypeCode.String:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsNumber(this string value)
|
||||
{
|
||||
return RegexHelper.IsNumber(value);
|
||||
}
|
||||
|
||||
public static bool IsAlphabet(this string value)
|
||||
{
|
||||
return RegexHelper.IsAlphabet(value);
|
||||
}
|
||||
|
||||
public static bool IsAlphabetOrNumber(this string value)
|
||||
{
|
||||
return RegexHelper.IsAlphabetOrNumber(value);
|
||||
}
|
||||
|
||||
public static bool IsJson(this string value)
|
||||
{
|
||||
return JsonHelper.IsJson(value);
|
||||
}
|
||||
|
||||
public static bool IsJTokenNullOrEmpty(this JToken token)
|
||||
{
|
||||
return (token == null) ||
|
||||
(token.Type == JTokenType.Array && !token.HasValues) ||
|
||||
(token.Type == JTokenType.Object && !token.HasValues) ||
|
||||
(token.Type == JTokenType.String && token.ToString() == string.Empty) ||
|
||||
(token.Type == JTokenType.Null);
|
||||
}
|
||||
|
||||
public static bool IsAjaxRequest(this Microsoft.AspNetCore.Http.HttpRequest request)
|
||||
{
|
||||
if (request == null)
|
||||
throw new ArgumentNullException("request");
|
||||
|
||||
if (request.Headers != null)
|
||||
return request.Headers["X-Requested-With"] == "XMLHttpRequest";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user