using System.Collections.Generic; using System.IO; using System.Linq; using AngleSharp; using AngleSharp.Html.Parser; namespace Rac.Tools { internal static class InternalUtility { public static byte[] ToBytes(this Stream stream) { using var ms = new MemoryStream(); stream.CopyTo(ms); return ms.ToArray(); } public static bool In(this T value, params T[] checkIn) { return checkIn.Contains(value); } public static string LoadHtml(byte[] body, out string charset) { using var stream = new MemoryStream(body); var htmlDocument = new HtmlParser().ParseDocument(stream); charset = htmlDocument.CharacterSet; return htmlDocument.ToHtml(); } public static void AddRange(this HashSet hashSet, IEnumerable toAdd) { foreach (var item in toAdd) { hashSet.Add(item); } } } }