Пример #1
0
        /// <summary>
        /// Load JSON files from disc or initialize default values and write all configuration files to disc
        /// </summary>
        internal void Load()
        {
            //Create the config directory if it doesn't exist
            Directory.CreateDirectory(cfiledir);

            //Set convert settings to output pretty indented json
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings {
                Formatting = Formatting.Indented
            };

            //Initialize settings
            addonSettings  = new AddonSettings();
            formatSettings = new FormatSettings();
            debugSettings  = new DebugSettings();
            outputSettings = new OutputSettings();

            string confString = "";

            //Load addon configuration
            if (File.Exists(cfiledir + addonFile))
            {
                confString    = File.ReadAllText(cfiledir + addonFile);
                addonSettings = JsonConvert.DeserializeObject <AddonSettings>(confString);
            }

            //Load format configuration
            if (File.Exists(cfiledir + formatFile))
            {
                confString     = File.ReadAllText(cfiledir + formatFile);
                formatSettings = JsonConvert.DeserializeObject <FormatSettings>(confString);
            }

            //Load debug configuration
            if (File.Exists(cfiledir + debugFile))
            {
                confString    = File.ReadAllText(cfiledir + debugFile);
                debugSettings = JsonConvert.DeserializeObject <DebugSettings>(confString);
            }

            //Load output configuration
            if (File.Exists(cfiledir + outputFile))
            {
                confString     = File.ReadAllText(cfiledir + outputFile);
                outputSettings = JsonConvert.DeserializeObject <OutputSettings>(confString);
            }

            Console.WriteLine("Configuration loaded");

            //Save the resulting JSON
            Save();
        }
Пример #2
0
        /// <summary>
        /// Load JSON files from disc or initialize default values and write all configuration files to disc
        /// </summary>
        internal void Load()
        {
            //Create the config directory if it doesn't exist
            Directory.CreateDirectory(cfiledir);

            //Load settings files
            addonSettings  = LoadFile <AddonSettings>(addonFile);
            rpcSettings    = LoadFile <RPCSettings>(rpcFile);
            formatSettings = LoadFile <FormatSettings>(formatFile);
            debugSettings  = LoadFile <DebugSettings>(debugFile);
            outputSettings = LoadFile <OutputSettings>(outputFile);

            Console.WriteLine("Configuration loaded");

            //Save the resulting JSON
            Save();
        }