示例#1
0
        public static void LoadSettings()
        {
            try
            {
                if (!Directory.Exists("configs"))
                {
                    Directory.CreateDirectory("configs");
                }

                var files = Directory.GetFiles("configs", "*.json");
                if (files.Length == 0)
                {
                    throw new Exception();
                }

                AllSettings     = files.Select(x => Settings.FromFile(x)).ToArray();
                CurrentSettings = AllSettings.FirstOrDefault(x => x.IsActive) ?? AllSettings.First();
            }
            catch (Exception ex)
            {
                CurrentSettings = new Settings("dummySettings");
                CurrentSettings.Save();
                Logger.Error("Failed to read settings!");
                Logger.PrintException(ex, true, false);
            }
        }
示例#2
0
        internal StoreSetting GetSetting(string name)
        {
            // Search local settings storage for setting
            var s = AllSettings.FirstOrDefault(y => y.SettingName == name);

            if (s == null)
            {
                s = new StoreSetting();
            }
            return(s);
        }