public static eSystemOptions ParseFromString(string i_UserChoice) { int numToCheck = int.Parse(i_UserChoice); int firstSystemOptions = (int)Enum.GetValues(typeof(eSystemOptions)).Cast <eSystemOptions>().First(); int lastSystemOptions = (int)Enum.GetValues(typeof(eSystemOptions)).Cast <eSystemOptions>().Last(); if (ValidationChecks.IsFloatNumberInRange(numToCheck, firstSystemOptions, lastSystemOptions) == false) { throw new ValueOutOfRangeException(numToCheck, firstSystemOptions, lastSystemOptions); } return((eSystemOptions)numToCheck); }
public static eVehicleStatus ParseFromString(string i_NumToParse) { int numToCheck = int.Parse(i_NumToParse); int firstVehicleStatus = (int)Enum.GetValues(typeof(eVehicleStatus)).Cast <eVehicleStatus>().First(); int lastVehicleStatus = (int)Enum.GetValues(typeof(eVehicleStatus)).Cast <eVehicleStatus>().Last(); if (ValidationChecks.IsFloatNumberInRange(numToCheck, firstVehicleStatus, lastVehicleStatus) == false) { throw new ValueOutOfRangeException(numToCheck, firstVehicleStatus, lastVehicleStatus); } return((eVehicleStatus)numToCheck); }
public static eNumOfCarDoors ParseFromString(string i_NumToParse) { int numToCheck = int.Parse(i_NumToParse); int firstNumOfCarDoors = (int)Enum.GetValues(typeof(eNumOfCarDoors)).Cast <eNumOfCarDoors>().First(); int carDoorsMaxSize = (int)Enum.GetValues(typeof(eNumOfCarDoors)).Cast <eNumOfCarDoors>().Last(); if (ValidationChecks.IsFloatNumberInRange(numToCheck, firstNumOfCarDoors, carDoorsMaxSize) == false) { throw new ValueOutOfRangeException(numToCheck, firstNumOfCarDoors, carDoorsMaxSize); } return((eNumOfCarDoors)numToCheck); }
public static eCarColor ParseFromString(string i_NumToParse) { int numToCheck = int.Parse(i_NumToParse); int firstCarColor = (int)Enum.GetValues(typeof(eCarColor)).Cast <eCarColor>().First(); int lastCarColor = (int)Enum.GetValues(typeof(eCarColor)).Cast <eCarColor>().Last(); if (ValidationChecks.IsFloatNumberInRange(numToCheck, firstCarColor, lastCarColor) == false) { throw new ValueOutOfRangeException(numToCheck, firstCarColor, lastCarColor); } return((eCarColor)numToCheck); }
public static eLicenseType ParseFromString(string i_NumToParse) { int numToCheck = int.Parse(i_NumToParse); int firstLicenseType = (int)Enum.GetValues(typeof(eLicenseType)).Cast <eLicenseType>().First(); int lastLicenseType = (int)Enum.GetValues(typeof(eLicenseType)).Cast <eLicenseType>().Last(); if (ValidationChecks.IsFloatNumberInRange(numToCheck, firstLicenseType, lastLicenseType) == false) { throw new ValueOutOfRangeException(numToCheck, firstLicenseType, lastLicenseType); } return((eLicenseType)numToCheck); }
public static void IsValidLicenseNumberStr(string i_LicenseNumberStr) { if (ValidationChecks.IsValidStrLen(i_LicenseNumberStr, k_LicenseNumberMinLen, k_LicenseNumberMaxLen) == false) { throw new ValueOutOfRangeException(k_LicenseNumberMinLen, k_LicenseNumberMaxLen, string.Format("The license number is not of range. Minimum digits is {0} and maximum {1}", k_LicenseNumberMinLen, k_LicenseNumberMaxLen)); } for (int i = 0; i < i_LicenseNumberStr.Length; i++) { if (char.IsLetterOrDigit(i_LicenseNumberStr[i]) == false) { throw new FormatException("The input must be digits or letters only"); } } }