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.IO; using Questionable.Model.Questing; namespace Questionable.FatePaths; internal static class AssemblyFateDefinitionLoader { private static readonly Lazy> Definitions = new Lazy>(LoadDefinitions, LazyThreadSafetyMode.ExecutionAndPublication); internal static TimeSpan? DecodeDuration { get; private set; } internal static Stream FateDefinitionSchema => typeof(AssemblyFateDefinitionLoader).Assembly.GetManifestResourceStream("Questionable.FatePaths.FateDefinitionSchema"); internal static IReadOnlyDictionary GetDefinitions() { return Definitions.Value; } private static IReadOnlyDictionary LoadDefinitions() { Stopwatch stopwatch = Stopwatch.StartNew(); using Stream stream = typeof(AssemblyFateDefinitionLoader).Assembly.GetManifestResourceStream("Questionable.FatePaths.FateBundle"); 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; } }