コード例 #1
0
ファイル: Settings.cs プロジェクト: MaT-PT/Exiled-Presence
        /// <summary>
        /// Attempt to store value with key
        /// </summary>
        public void ParseValue(string key, string val)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException("Empty key provided");
            }

            // Ignored value
            if (val.StartsWith("#"))
            {
                val = null;
            }

            // Convert string key to enum
            SettingType type;

            try {
                type = SettingMethods.GetType(key);
            } catch (InvalidOperationException) {
                return;
            }

            _userSettings[type] = val;

            // Validate user input
            type.Validate(val);
            Console.WriteLine($"[CONF] {type} - {val}");
        }
コード例 #2
0
ファイル: Settings.cs プロジェクト: MaT-PT/Exiled-Presence
 /// <summary>
 /// If user settings has same nr of settings as default settings
 /// </summary>
 public void VerifyAllSettingsPresent()
 {
     // Check if all mandatory config values are present
     foreach (SettingType type in Enum.GetValues(typeof(SettingType)))
     {
         if (!_userSettings.ContainsKey(type))
         {
             throw new ArgumentException($"Missing config option '{SettingMethods.GetKey(type)}'. " +
                                         "Please backup and reset the config");
         }
     }
 }