123456789101112131415161718192021222324252627282930313233343536373839 |
- 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<T>(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<T>(this HashSet<T> hashSet, IEnumerable<T> toAdd)
- {
- foreach (var item in toAdd)
- {
- hashSet.Add(item);
- }
- }
- }
- }
|