27 lines
721 B
C#
27 lines
721 B
C#
|
|
using Cowain.Base.Abstractions.Navigation;
|
|
using Cowain.Base.Models.Navigation;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace Cowain.Base.Helpers;
|
|
|
|
/// <summary>
|
|
/// 参数异常助手类
|
|
/// </summary>
|
|
public class ArgumentExceptionHelper
|
|
{
|
|
public static void ThrowIfNullOrEmpty(string? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)
|
|
{
|
|
if (string.IsNullOrEmpty(argument))
|
|
throw new ArgumentNullException(paramName);
|
|
}
|
|
|
|
public static void ThrowIfOutOfRange(bool argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)
|
|
{
|
|
if (argument)
|
|
throw new ArgumentOutOfRangeException(paramName);
|
|
}
|
|
|
|
}
|
|
|