Exemple #1
0
        public void ConvertName()
        {
            var converted = _fileNameConverter.ConvertToTypeScript(
                "MyItemDto.cs",
                new FileNameConversionOptions(useKebabCase: false, appendModelSuffix: false));

            Assert.Equal("myItemDto.ts", converted);
        }
Exemple #2
0
        public void Handle()
        {
            string inputLine;

            while ((inputLine = _stdio.ReadLine()) != "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);
            }
        }