Beispiel #1
0
        /// <summary>
        /// Saves loaded configuration.
        /// </summary>
        public static void Save()
        {
            if (Loaded == null)
            {
                throw new InvalidOperationException($"Loaded configuration is null.");
            }

            var directory = Path.GetDirectoryName(ConfigurationPath);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory ?? throw new InvalidOperationException());
            }

            JEMFile.SaveTextToFile(ConfigurationPath, JsonConvert.SerializeObject(Loaded));
        }
Beispiel #2
0
        /// <summary>
        /// Loads configuration.
        /// </summary>
        public static void Load()
        {
            if (File.Exists(ConfigurationPath))
            {
                try
                {
                    Loaded = JsonConvert.DeserializeObject <SMCConfiguration>(
                        JEMFile.LoadTextFromFile(ConfigurationPath));
                    return;
                }
                catch (Exception e)
                {
                    JEMLogger.LogException(e, "Failed to load SMCConfiguration file.");
                }
            }

            Loaded = new SMCConfiguration();
            Save();
        }