2019-01-13 20:01:16 +00:00
|
|
|
using System;
|
2019-12-10 23:13:57 +00:00
|
|
|
using System.Security.Cryptography;
|
2019-03-25 21:25:32 +00:00
|
|
|
using System.Text;
|
2018-12-27 23:27:57 +00:00
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
namespace MediaBrowser.Common.Extensions
|
|
|
|
{
|
|
|
|
/// <summary>
|
2019-12-10 23:13:57 +00:00
|
|
|
/// Class BaseExtensions.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
2023-05-22 20:48:09 +00:00
|
|
|
public static partial class BaseExtensions
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
2023-05-22 20:48:09 +00:00
|
|
|
// http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net
|
|
|
|
[GeneratedRegex(@"<(.|\n)*?>")]
|
|
|
|
private static partial Regex StripHtmlRegex();
|
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Strips the HTML.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="htmlString">The HTML string.</param>
|
2019-09-20 10:42:08 +00:00
|
|
|
/// <returns><see cref="string" />.</returns>
|
2018-12-27 23:27:57 +00:00
|
|
|
public static string StripHtml(this string htmlString)
|
2023-05-22 20:48:09 +00:00
|
|
|
=> StripHtmlRegex().Replace(htmlString, string.Empty).Trim();
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2019-09-20 10:42:08 +00:00
|
|
|
/// Gets the Md5.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
2019-09-20 10:42:08 +00:00
|
|
|
/// <param name="str">The string.</param>
|
|
|
|
/// <returns><see cref="Guid" />.</returns>
|
2018-12-27 23:27:57 +00:00
|
|
|
public static Guid GetMD5(this string str)
|
|
|
|
{
|
2019-12-10 23:13:57 +00:00
|
|
|
#pragma warning disable CA5351
|
2022-04-09 18:17:07 +00:00
|
|
|
return new Guid(MD5.HashData(Encoding.Unicode.GetBytes(str)));
|
2019-12-10 23:13:57 +00:00
|
|
|
#pragma warning restore CA5351
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|