public static ConvertModel Parse(Query query) { string[] split = query.Search.Split(' '); InputInterpreter.ShorthandFeetInchHandler(ref split, CultureInfo.CurrentCulture); InputInterpreter.InputSpaceInserter(ref split); if (split.Length != 4) { // deny any other queries than: // 10 ft in cm // 10 ft to cm return(null); } InputInterpreter.DegreePrefixer(ref split); if (!double.TryParse(split[0], out double value)) { return(null); } return(new ConvertModel() { Value = value, FromUnit = split[1], ToUnit = split[3], }); }
public List <Result> Query(Query query) { if (query == null) { throw new ArgumentNullException(paramName: nameof(query)); } // Parse ConvertModel convertModel = InputInterpreter.Parse(query); if (convertModel == null) { return(new List <Result>()); } // Convert return(UnitHandler.Convert(convertModel) .Select(x => GetResult(x)) .ToList()); }