BaseExtensions.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Globalization;
  3. using System.Text.RegularExpressions;
  4. using MediaBrowser.Model.Cryptography;
  5. namespace MediaBrowser.Common.Extensions
  6. {
  7. /// <summary>
  8. /// Class BaseExtensions
  9. /// </summary>
  10. public static class BaseExtensions
  11. {
  12. public static ICryptoProvider CryptographyProvider { get; set; }
  13. /// <summary>
  14. /// Strips the HTML.
  15. /// </summary>
  16. /// <param name="htmlString">The HTML string.</param>
  17. /// <returns>System.String.</returns>
  18. public static string StripHtml(this string htmlString)
  19. {
  20. // http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net
  21. const string pattern = @"<(.|\n)*?>";
  22. return Regex.Replace(htmlString, pattern, string.Empty).Trim();
  23. }
  24. /// <summary>
  25. /// Gets the M d5.
  26. /// </summary>
  27. /// <param name="str">The STR.</param>
  28. /// <returns>Guid.</returns>
  29. public static Guid GetMD5(this string str)
  30. {
  31. return CryptographyProvider.GetMD5(str);
  32. }
  33. }
  34. }