Exemple #1
0
        public static int readInteger(string key, string SettingsFilePath)
        {
            string value = readString(key, SettingsFilePath);

            if (!DataValidation.ValidateInteger(value))
            {
                throw new ArgumentException("That is not an integer!");
            }
            return(int.Parse(value));
        }
Exemple #2
0
        public static double readDouble(string key, string SettingsFilePath)
        {
            string value = readString(key, SettingsFilePath);

            if (!DataValidation.ValidateDouble(value))
            {
                throw new ArgumentException("That is not a double!");
            }
            return(double.Parse(value));
        }
Exemple #3
0
        public static string readStringAndValidate(string key, List <string> validationRegexPatternList, string SettingsFilePath)
        {
            string value = readString(key, SettingsFilePath);

            if (!DataValidation.ValidateBasedOnRegexList(value, validationRegexPatternList))
            {
                throw new ArgumentException("That value does not match one or more of the provided regexes!");
            }
            return(value);
        }
Exemple #4
0
        public static string readStringAndValidate(string key, string validationRegexPattern, string SettingsFilePath)
        {
            string value = readString(key, SettingsFilePath);

            if (!DataValidation.ValidateBasedOnRegex(value, validationRegexPattern))
            {
                throw new ArgumentException("That value does not match the provided regex!");
            }
            return(value);
        }
Exemple #5
0
        public static bool readBoolean(string key, string SettingsFilePath)
        {
            int value = readInteger(key, SettingsFilePath); // Will throw an exception if a non-integer is entered (so no need to notify the programmer that a non-integer was submitted below)

            if (!DataValidation.ValidateBooleanInteger(value.ToString()))
            {
                throw new ArgumentException("That is not a boolean integer! Boolean integers must be either 0 (false) or 1 (true).");
            }
            return(value == 1);
        }
Exemple #6
0
 public static void writeStringAndValidate(string key, string value, List <string> validationRegexPatternList, string SettingsFilePath)
 {
     if (!DataValidation.ValidateBasedOnRegexList(value, validationRegexPatternList))
     {
         throw new ArgumentException("That value does not match one or more of the provided regexes!");
     }
     else
     {
         writeString(key, value, SettingsFilePath);
     }
 }
Exemple #7
0
 public static void writeStringAndValidate(string key, string value, string validationRegexPattern, string SettingsFilePath)
 {
     if (!DataValidation.ValidateBasedOnRegex(value, validationRegexPattern))
     {
         throw new ArgumentException("That value does not match the provided regex!");
     }
     else
     {
         writeString(key, value, SettingsFilePath);
     }
 }