using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Security.Cryptography; using System.Threading; using Questionable.Model.Gathering; using Questionable.Model.IO; namespace Questionable.GatheringPaths; internal static class AssemblyGatheringLocationLoader { private static readonly Lazy> Locations = new Lazy>(LoadLocations, LazyThreadSafetyMode.ExecutionAndPublication); internal static TimeSpan? DecodeDuration { get; private set; } internal static Stream GatheringSchema => typeof(AssemblyGatheringLocationLoader).Assembly.GetManifestResourceStream("Questionable.GatheringPaths.GatheringLocationSchema"); internal static IReadOnlyDictionary GetLocations() { return Locations.Value; } private static IReadOnlyDictionary LoadLocations() { Stopwatch stopwatch = Stopwatch.StartNew(); using Stream stream = typeof(AssemblyGatheringLocationLoader).Assembly.GetManifestResourceStream("Questionable.GatheringPaths.GatheringBundle"); byte[] array = PathBundleSecret.Key(); List> list = PathBundle.Deserialize(stream, array); CryptographicOperations.ZeroMemory(array); Dictionary dictionary = new Dictionary(list.Count); foreach (var (s, value) in list) { dictionary[ushort.Parse(s, CultureInfo.InvariantCulture)] = value; } DecodeDuration = stopwatch.Elapsed; return dictionary; } }