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)); }
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)); }
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); }
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); }
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); }
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); } }
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); } }