ParamterCheckExtensions
/// <summary>
/// 验证指定值的断言表达式是否为真,不为值抛出<see cref="Exception"/>异常
/// </summary>
/// <param name="value"></param>
/// <param name="assertionFunc">要验证的断言表达式</param>
/// <param name="message">异常消息</param>
public static void Required<T>(this T value, Func<T, bool> assertionFunc, string message)
/// <summary>
/// 验证指定值的断言表达式是否为真,不为真抛出<typeparamref name="TException"/>异常
/// </summary>
/// <typeparam name="T">要判断的值的类型</typeparam>
/// <typeparam name="TException">抛出的异常类型</typeparam>
/// <param name="value">要判断的值</param>
/// <param name="assertionFunc">要验证的断言表达式</param>
/// <param name="message">异常消息</param>
public static void Required<T, TException>(this T value, Func<T, bool> assertionFunc, string message) where TException : Exception
/// <summary>
/// 检查参数不能为空引用,否则抛出<see cref="ArgumentNullException"/>异常。
/// </summary>
/// <param name="value"></param>
/// <param name="paramName">参数名称</param>
/// <exception cref="ArgumentNullException"></exception>
public static void CheckNotNull<T>(this T value, string paramName) where T : class
/// <summary>
/// 检查字符串不能为空引用或空字符串,否则抛出<see cref="ArgumentNullException"/>异常或<see cref="ArgumentException"/>异常。
/// </summary>
/// <param name="value"></param>
/// <param name="paramName">参数名称。</param>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException"></exception>
public static void CheckNotNullOrEmpty(this string value, string paramName)
/// <summary>
/// 检查Guid值不能为Guid.Empty,否则抛出<see cref="ArgumentException"/>异常。
/// </summary>
/// <param name="value"></param>
/// <param name="paramName">参数名称。</param>
/// <exception cref="ArgumentException"></exception>
public static void CheckNotEmpty(this Guid value, string paramName)
/// <summary>
/// 检查集合不能为空引用或空集合,否则抛出<see cref="ArgumentNullException"/>异常或<see cref="ArgumentException"/>异常。
/// </summary>
/// <typeparam name="T">集合项的类型。</typeparam>
/// <param name="collection"></param>
/// <param name="paramName">参数名称。</param>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException"></exception>
public static void CheckNotNullOrEmpty<T>(this IEnumerable<T> collection, string paramName)
/// <summary>
/// 检查参数必须小于[或可等于,参数canEqual]指定值,否则抛出<see cref="ArgumentOutOfRangeException"/>异常。
/// </summary>
/// <typeparam name="T">参数类型。</typeparam>
/// <param name="value"></param>
/// <param name="paramName">参数名称。</param>
/// <param name="target">要比较的值。</param>
/// <param name="canEqual">是否可等于。</param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static void CheckLessThan<T>(this T value, string paramName, T target, bool canEqual = false) where T : IComparable<T>
/// <summary>
/// 检查参数必须大于[或可等于,参数canEqual]指定值,否则抛出<see cref="ArgumentOutOfRangeException"/>异常。
/// </summary>
/// <typeparam name="T">参数类型。</typeparam>
/// <param name="value"></param>
/// <param name="paramName">参数名称。</param>
/// <param name="target">要比较的值。</param>
/// <param name="canEqual">是否可等于。</param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static void CheckGreaterThan<T>(this T value, string paramName, T target, bool canEqual = false) where T : IComparable<T>
/// <summary>
/// 检查参数必须在指定范围之间,否则抛出<see cref="ArgumentOutOfRangeException"/>异常。
/// </summary>
/// <typeparam name="T">参数类型。</typeparam>
/// <param name="value"></param>
/// <param name="paramName">参数名称。</param>
/// <param name="start">比较范围的起始值。</param>
/// <param name="end">比较范围的结束值。</param>
/// <param name="startEqual">是否可等于起始值</param>
/// <param name="endEqual">是否可等于结束值</param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static void CheckBetween<T>(this T value, string paramName, T start, T end, bool startEqual = false, bool endEqual = false)
/// <summary>
/// 检查指定路径的文件夹必须存在,否则抛出<see cref="DirectoryNotFoundException"/>异常。
/// </summary>
/// <param name="directory"></param>
/// <param name="paramName">参数名称。</param>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="DirectoryNotFoundException"></exception>
public static void CheckDirectoryExists(this string directory, string paramName = null)
/// <summary>
/// 检查指定路径的文件必须存在,否则抛出<see cref="FileNotFoundException"/>异常。
/// </summary>
/// <param name="filename"></param>
/// <param name="paramName">参数名称。</param>
/// <exception cref="ArgumentNullException">当文件路径为null时</exception>
/// <exception cref="FileNotFoundException">当文件路径不存在时</exception>
public static void CheckFileExists(this string filename, string paramName = null)