public void Handle() { string inputLine; while ((inputLine = _stdio.ReadLine()) != "EXIT") { Output output; try { var input = JsonConvert.DeserializeObject <Input>(inputLine, _serializerSettings); var convertedCode = _codeConverter.ConvertToTypeScript(input.Code, input.MapToCodeConversionOptions()); output = new Output { Succeeded = true, ConvertedCode = convertedCode }; } catch (Exception ex) { output = new Output { Succeeded = false, ErrorMessage = ex.Message }; } var outputLine = JsonConvert.SerializeObject(output, _serializerSettings); _stdio.WriteLine(outputLine); } }
public void Handle() { while (_stdio.ReadLine() is var inputLine && inputLine != "EXIT") { Output output; try { var input = JsonConvert.DeserializeObject <Input>(inputLine, _serializerSettings); var codeConversionOptions = input.MapToCodeConversionOptions(); var convertedCode = _codeConverter.ConvertToTypeScript(input.Code, codeConversionOptions); var convertedFileName = string.IsNullOrWhiteSpace(input.FileName) ? null : _fileNameConverter.ConvertToTypeScript(input.FileName, codeConversionOptions); output = new Output { Succeeded = true, ConvertedCode = convertedCode, ConvertedFileName = convertedFileName }; } catch (Exception ex) { output = new Output { Succeeded = false, ErrorMessage = ex.Message }; } var outputLine = JsonConvert.SerializeObject(output, _serializerSettings); _stdio.WriteLine(outputLine); } }