UtilCheckString.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Reflection;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace NXWMS.Code.Verifications
  10. {
  11. /// <summary>
  12. /// 字符串验证
  13. /// </summary>
  14. public static class UtilCheckString
  15. {
  16. /// <summary>
  17. /// 获取动态参数空结果处理
  18. /// </summary>
  19. /// <param name="paramArray"></param>
  20. /// <returns></returns>
  21. public static bool GetDynamicParmaValidateResult(params object[] paramArray)
  22. {
  23. foreach (var item in paramArray)
  24. {
  25. if (string.IsNullOrWhiteSpace(item.ToString()))
  26. {
  27. return false;
  28. }
  29. }
  30. return true;
  31. }
  32. /// <summary>
  33. /// 获取动态参数空结果处理T
  34. /// </summary>
  35. /// <typeparam name="T"></typeparam>
  36. /// <param name="data"></param>
  37. /// <returns></returns>
  38. public static bool GetDynamicParmaValidateResult<T>(T data) where T : class
  39. {
  40. var props = typeof(T).GetProperties();
  41. foreach (PropertyInfo detail in props)
  42. {
  43. if (props.Where(m => string.IsNullOrWhiteSpace(m.ToString())).Count() > 0)
  44. {
  45. return false;
  46. }
  47. }
  48. return true;
  49. }
  50. }
  51. }