Helper.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. namespace RKISPATTERN.Helpers
  9. {
  10. public class Helper
  11. {
  12. public static void CloseWindow<T>()
  13. {
  14. foreach (var wnd in App.Current.Windows)
  15. {
  16. if (wnd is T)
  17. ((Window)wnd).Close();
  18. }
  19. }
  20. public static bool CheckLoginPass(string str)
  21. {
  22. if (string.IsNullOrEmpty(str))
  23. return false;
  24. Regex regex = new Regex(@"[0-9a-zA-Z]{6,30}");
  25. return regex.IsMatch(str);
  26. }
  27. public static bool CheckPhone(string phone)
  28. {
  29. if (string.IsNullOrEmpty(phone))
  30. return false;
  31. Regex regex = new Regex(@"^\+[\d]{11}$");
  32. return regex.IsMatch(phone);
  33. }
  34. public static bool CheckName(string name)
  35. {
  36. if (string.IsNullOrEmpty(name))
  37. return false;
  38. return true;
  39. }
  40. }
  41. }