ArgumentValidator.cs 812 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. namespace PaySharp.Alipay.Util
  3. {
  4. /// <summary>
  5. /// 参数校验类
  6. /// </summary>
  7. public class ArgumentValidator
  8. {
  9. public static void CheckArgument(bool expression, string errorMessage)
  10. {
  11. if (!expression)
  12. {
  13. throw new Exception(errorMessage);
  14. }
  15. }
  16. public static void CheckNotNull(object value, string errorMessage)
  17. {
  18. if (value == null)
  19. {
  20. throw new Exception(errorMessage);
  21. }
  22. }
  23. public static void EnsureNull(object value, string errorMessage)
  24. {
  25. if (value != null)
  26. {
  27. throw new Exception(errorMessage);
  28. }
  29. }
  30. }
  31. }