public override string Parse(string input, out Error error) { string[] matches = GetMatches(input, REGEX_PATTERN); if (matches.Length == 0) { if (input.Contains("'"))//check is input contains quote { error = new UnclosedQuoteError(); } else { error = new AnotherParameterError(); } return(input); } string result = String.Join("", matches.ToArray()); error = new NoneError(); return(result.Remove(0, 1) //removing .Remove(result.Length - 2, 1)); //quotes }
public override short Parse(string input, out Error error) { input = input.Replace(" ", ""); string[] matches = GetMatches(input, REGEX_PATTERN); if (matches.Length == 0) { if (Regex.IsMatch(input, REGEX_LETTERS_PATTERN)) { error = new LetterToDigitError(); } else { error = new AnotherParameterError(); } return(default(short)); } if (!short.TryParse(matches[0], out short result) || short.Parse(matches[0]) < 1) { error = new OutOfRangeNumberError(); return(default(short)); } error = new NoneError(); return(short.Parse(matches[0])); }