Exemple #1
0
 private bool Test(int index)
 {
     bool result = false;
     string inputFileName = string.Format(@"..\..\InputFiles\wsdl\Wsdl{0:00}.Hello.wsdl", index);
     string expectedFileName = string.Format(@"..\..\ExpectedFiles\soal\Wsdl{0:00}.Hello.soal", index);
     string outputFileName = string.Format(@"..\..\OutputFiles\soal\Wsdl{0:00}.Hello.soal", index);
     string outputLogFileName = string.Format(@"..\..\OutputFiles\soal\Wsdl{0:00}.Hello.log", index);
     string outputDirectory = string.Format(@"..\..\OutputFiles\soal", index);
     Model model = new Model();
     using (ModelContextScope scope = new ModelContextScope(model))
     using (ModelCompilerContextScope compilerScope = new ModelCompilerContextScope(new DefaultModelCompiler()))
     {
         SoalImporter.Import(inputFileName);
         using (StreamWriter writer = new StreamWriter(outputLogFileName))
         {
             foreach (var msg in ModelCompilerContext.Current.Diagnostics.GetMessages(true))
             {
                 writer.WriteLine(msg);
             }
         }
         Assert.IsFalse(ModelCompilerContext.Current.Diagnostics.HasErrors());
         Directory.CreateDirectory(outputDirectory);
         string outputSoal = null;
         SoalPrinter printer = new SoalPrinter(model.Instances);
         using (StreamWriter writer = new StreamWriter(outputFileName))
         {
             outputSoal = printer.Generate();
             writer.WriteLine(outputSoal);
         }
         string expectedSoal = null;
         using (StreamReader reader = new StreamReader(expectedFileName))
         {
             expectedSoal = reader.ReadToEnd();
         }
         Assert.AreEqual(expectedSoal, outputSoal);
         return result;
     }
 }
Exemple #2
0
 static void Main(string[] args)
 {
     try
     {
         string inputFileName = null;
         string outputFileName = null;
         for (int i = 0; i < args.Length; i++)
         {
             if (args[i].StartsWith("-"))
             {
                 if (i + 1 < args.Length)
                 {
                     if (args[i] == "-o")
                     {
                         outputFileName = args[++i];
                     }
                     else
                     {
                         Console.WriteLine("Unknown option: '" + args[i] + "'");
                     }
                 }
                 else
                 {
                     Console.WriteLine("Unknown option: '" + args[i] + "'");
                 }
             }
             else
             {
                 inputFileName = args[i];
             }
         }
         if (inputFileName == null)
         {
             Console.WriteLine("Usage:");
             Console.WriteLine("  SoalImport.exe [options] [input.wsdl or input.xsd]");
             Console.WriteLine("Options:");
             Console.WriteLine("  -o [output.soal]: output SOAL file");
             return;
         }
         if (outputFileName == null)
         {
             outputFileName = Path.ChangeExtension(inputFileName, ".soal");
         }
         if (!File.Exists(inputFileName))
         {
             Console.WriteLine("Could not find file: " + inputFileName);
             return;
         }
         Model model = new Model();
         using (ModelContextScope scope = new ModelContextScope(model))
         {
             SoalImporter.Import(inputFileName);
             foreach (var msg in ModelCompilerContext.Current.Diagnostics.GetMessages(true))
             {
                 Console.WriteLine(msg);
             }
             //if (!ModelCompilerContext.Current.Diagnostics.HasErrors())
             {
                 SoalPrinter printer = new SoalPrinter(model.Instances);
                 using (StreamWriter writer = new StreamWriter(outputFileName))
                 {
                     writer.WriteLine(printer.Generate());
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex);
     }
 }