namespace Il2CppInspector.Redux.FrontendCore.Outputs; public static class OutputFormatRegistry { public static IEnumerable AvailableOutputFormats => OutputFormats.Keys; private static readonly Dictionary OutputFormats = []; public static void RegisterOutputFormat() where T : IOutputFormatProvider, new() { if (OutputFormats.ContainsKey(T.Id)) throw new InvalidOperationException("An output format with this id was already registered."); OutputFormats[T.Id] = new T(); } public static IOutputFormat GetOutputFormat(string id) { if (!OutputFormats.TryGetValue(id, out var format)) throw new ArgumentException($"Failed to find output format for id {id}", nameof(id)); return format; } private static void RegisterBuiltinOutputFormats() { RegisterOutputFormat(); RegisterOutputFormat(); RegisterOutputFormat(); RegisterOutputFormat(); RegisterOutputFormat(); } static OutputFormatRegistry() { RegisterBuiltinOutputFormats(); } }