baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
+65
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace GuangFu.StringTracing.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// 扩展方法类
|
||||
/// </summary>
|
||||
public static class Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 安全转换为字符串(处理null和DBNull)
|
||||
/// </summary>
|
||||
public static string ToStringEx(this object obj)
|
||||
{
|
||||
if (obj == null || obj == DBNull.Value)
|
||||
return string.Empty;
|
||||
return obj.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安全转换为整数(处理null和DBNull)
|
||||
/// </summary>
|
||||
public static int ToInt(this object obj)
|
||||
{
|
||||
if (obj == null || obj == DBNull.Value)
|
||||
return 0;
|
||||
|
||||
int result;
|
||||
if (int.TryParse(obj.ToString(), out result))
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安全转换为可为空的DateTime(处理null和DBNull)
|
||||
/// </summary>
|
||||
public static DateTime? ToDateTimeNullable(this object obj)
|
||||
{
|
||||
if (obj == null || obj == DBNull.Value)
|
||||
return null;
|
||||
|
||||
DateTime result;
|
||||
if (DateTime.TryParse(obj.ToString(), out result))
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串是否为空或空白
|
||||
/// </summary>
|
||||
public static bool IsNullOrEmpty(this string str)
|
||||
{
|
||||
return string.IsNullOrEmpty(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串是否为空、空白或仅包含空格
|
||||
/// </summary>
|
||||
public static bool IsNullOrWhiteSpace(this string str)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user