using System;
namespace LeaRun.Util.Extension
{
///
/// 验证扩展
///
public static partial class Extensions
{
///
/// 检测空值,为null则抛出ArgumentNullException异常
///
/// 对象
/// 参数名
public static void CheckNull(this object obj, string parameterName)
{
if (obj == null)
throw new ArgumentNullException(parameterName);
}
///
/// 是否为空
///
/// 值
public static bool IsEmpty(this string value)
{
return string.IsNullOrWhiteSpace(value);
}
///
/// 是否为空
///
/// 值
public static bool IsEmpty(this Guid? value)
{
if (value == null)
return true;
return IsEmpty(value.Value);
}
///
/// 是否为空
///
/// 值
public static bool IsEmpty(this Guid value)
{
if (value == Guid.Empty)
return true;
return false;
}
///
/// 是否为空
///
/// 值
public static bool IsEmpty(this object value)
{
if (value != null && !string.IsNullOrEmpty(value.ToString()))
{
return false;
}
else
{
return true;
}
}
}
}