using System; using Microsoft.AspNetCore.Http; namespace Myshipping.Core; /// /// 验证扩展类 /// public static partial class Extensions { /// /// 检查 Object 是否为 NULL /// /// /// public static bool IsEmpty(this object value) { return value == null || string.IsNullOrEmpty(value.ParseToString()); } /// /// 检查 Object 是否为 NULL 或者 0 /// /// /// public static bool IsNullOrZero(this object value) { return value == null || value.ParseToString().Trim() == "0"; } /// /// 检查是否为 AJAX 请求 /// /// /// public static bool IsAjaxRequest(this HttpRequest request) { if (request == null) throw new ArgumentNullException(nameof(request)); if (request.Headers != null) return request.Headers["X-Requested-With"] == "XMLHttpRequest"; return false; } }