private static void GenerateViaCodeDOM(string outputFileName, System.CodeDom.Compiler.CodeDomProvider provider, System.CodeDom.CodeCompileUnit compileUnit)
    {
        System.CodeDom.Compiler.ICodeGenerator     gen = provider.CreateGenerator();
        System.CodeDom.Compiler.IndentedTextWriter tw;

        tw = new System.CodeDom.Compiler.IndentedTextWriter(new System.IO.StreamWriter(outputFileName, false), "	");
        System.CodeDom.Compiler.CodeGeneratorOptions options = new System.CodeDom.Compiler.CodeGeneratorOptions();
        options.BracingStyle = "C";
        gen.GenerateCodeFromCompileUnit(compileUnit, tw, options);
        tw.Flush();
        tw.Close();
    }
예제 #2
0
        public static void GenerateViaCodeDOM(string outputFileName,
                                              System.CodeDom.Compiler.CodeDomProvider provider,
                                              System.CodeDom.CodeCompileUnit compileunit)
        {
            System.CodeDom.Compiler.ICodeGenerator     gen = provider.CreateGenerator();
            System.CodeDom.Compiler.IndentedTextWriter tw;

            try
            {
                tw = new System.CodeDom.Compiler.IndentedTextWriter(new System.IO.StreamWriter(outputFileName, false), "    ");
                gen.GenerateCodeFromCompileUnit(compileunit, tw, new System.CodeDom.Compiler.CodeGeneratorOptions());
                tw.Flush();
                tw.Close();
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                throw;
            }
        }
예제 #3
0
 public static void GenerateCode(string fileName,
                                 System.CodeDom.Compiler.CodeDomProvider provider,
                                 System.CodeDom.CodeCompileUnit compileUnit)
 {
     System.CodeDom.Compiler.ICodeGenerator     gen = provider.CreateGenerator();
     System.CodeDom.Compiler.IndentedTextWriter tw  = null;
     try
     {
         tw = new System.CodeDom.Compiler.IndentedTextWriter(new System.IO.StreamWriter(fileName, false), "	");
         gen.GenerateCodeFromCompileUnit(compileUnit, tw, new System.CodeDom.Compiler.CodeGeneratorOptions());
     }
     finally
     {
         if (tw != null)
         {
             tw.Flush();
             tw.Close();
         }
     }
 }