using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; namespace FNZCM.Core { public interface IConfigFile { string ListenPrefix { get; } IReadOnlyCollection AliasPrefix { get; } IReadOnlyCollection AccessControlAllowOrigin { get; } string M3uPrefix { get; } string Title { get; } string AdminPassword { get; } bool LibraryPathFollowLink { get; } public string RealConfigFilePath { get; } IReadOnlyDictionary Libraries { get; } string[] MediaFilePattern { get; } string[] BkFilePattern { get; } IReadOnlyDictionary Modules { get; } } public class ConfigFile : IConfigFile { static string ConfigFilePath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json"); public string RealConfigFilePath => new FileInfo(ConfigFilePath).LinkTarget ?? ConfigFilePath; static ConfigFile() => Reload(); public static void Reload() => Instance = JsonConvert.DeserializeObject(File.ReadAllText(ConfigFilePath)); public string ListenPrefix { get; set; } public IReadOnlyCollection AliasPrefix { get; set; } public IReadOnlyCollection AccessControlAllowOrigin { get; set; } public string M3uPrefix { get; set; } public string Title { get; set; } public string AdminPassword { get; set; } public bool LibraryPathFollowLink { get; set; } public IReadOnlyDictionary Libraries { get; set; } public string[] MediaFilePattern { get; set; } public string[] BkFilePattern { get; set; } public static IConfigFile Instance { get; private set; } public IReadOnlyDictionary Modules { get; set; } } public class ModuleEntry { public bool IsDefault { get; set; } public string DisplayText { get; set; } public string Path { get; set; } public bool EnableFallbackRoute { get; set; } public string DefaultDocument { get; set; } public string HtmlBaseReplace { get; set; } } }