ListHelper.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace MediaBrowser.Model.Extensions
  5. {
  6. public static class ListHelper
  7. {
  8. public static bool ContainsIgnoreCase(List<string> list, string value)
  9. {
  10. if (value == null)
  11. {
  12. throw new ArgumentNullException("value");
  13. }
  14. return list.Contains(value, StringComparer.OrdinalIgnoreCase);
  15. }
  16. public static bool ContainsIgnoreCase(string[] list, string value)
  17. {
  18. if (value == null)
  19. {
  20. throw new ArgumentNullException("value");
  21. }
  22. return list.Contains(value, StringComparer.OrdinalIgnoreCase);
  23. }
  24. public static bool ContainsAnyIgnoreCase(string[] list, string[] values)
  25. {
  26. if (values == null)
  27. {
  28. throw new ArgumentNullException("values");
  29. }
  30. foreach (string val in values)
  31. {
  32. if (ContainsIgnoreCase(list, val))
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. }
  40. }