Exemple #1
0
        public void Parse(string filePath, string option)
        {
            using (var output = new StringWriter()) {
                System.Console.SetOut(output);

                Program.Main(new[] { filePath, option });

                var actual = output.ToString()
                             .ReplaceNewlinesForWindows();
                var expected = SyntaxTreeGenerators.GetProcessorByPath(filePath)
                               .GenerateXmlFromCodePath(filePath)
                               .ToString()
                               .ReplaceNewlinesForWindows();
                Assert.That(actual.StartsWith(expected), Is.True);
            }
        }
Exemple #2
0
        public static void ParseXmlToCode(
            IEnumerable <string> filePaths,
            string parserName, OutputType isOutputFile,
            string outputPath)
        {
            var parser        = SyntaxTreeGenerators.GetProcessorByNameWithVersion(parserName);
            var getOutPutFunc = GetGetOutputFunc(
                isOutputFile, outputPath,
                parser.DefaultExtension);

            foreach (var path in filePaths)
            {
                var code = parser.GenerateCodeFromXmlPath(path);
                getOutPutFunc.Item1(path, code);
            }
            getOutPutFunc.Item2();
        }
Exemple #3
0
        public static void ParseCodeToXml(
            IEnumerable <string> filePaths,
            string parserName, OutputType outputType,
            string outputPath)
        {
            var getOutPutFunc = GetGetOutputFunc(outputType, outputPath, ".xml");

            foreach (var path in filePaths)
            {
                var extension = Path.GetExtension(path);
                var parser    = parserName != null
                        ? SyntaxTreeGenerators.GetProcessorByNameWithVersion(parserName)
                        : SyntaxTreeGenerators.GetProcessorByExtension(extension);

                if (parser == null)
                {
                    continue;
                }
                var ast = parser.GenerateXmlFromCodePath(path);
                getOutPutFunc.Item1(path, ast.ToString());
            }
            getOutPutFunc.Item2();
        }