BaseExtensions.cs 877 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Security.Cryptography;
  7. namespace MediaBrowser.Common.Extensions
  8. {
  9. public static class BaseExtensions
  10. {
  11. static MD5CryptoServiceProvider md5Provider = new MD5CryptoServiceProvider();
  12. public static Guid GetMD5(this string str)
  13. {
  14. lock (md5Provider)
  15. {
  16. return new Guid(md5Provider.ComputeHash(Encoding.Unicode.GetBytes(str)));
  17. }
  18. }
  19. public static bool ContainsStartsWith(this List<string> lst, string value)
  20. {
  21. foreach (var str in lst)
  22. {
  23. if (str.StartsWith(value, StringComparison.OrdinalIgnoreCase)) return true;
  24. }
  25. return false;
  26. }
  27. }
  28. }