Exemplo n.º 1
0
        static void Main(string[] args)
        {
            options = new CommandLineOptions(args);

            // code will go to standard output
            if (options.UseColorConsoleOutput)
            {
                ConsolePrinter console_printer = new ConsolePrinter();
                codePrinter = console_printer;
                logPrinter  = console_printer; // ConsolePrinter writes log to stderr
            }
            else
            {
                codePrinter = new TextWriterPrinter(Console.Out);
                logPrinter  = new TextWriterPrinter(Console.Error);
            }

            try
            {
                string assembly_path = options.AssemblyFilePath;
                Debug.Assert(!String.IsNullOrEmpty(assembly_path));

                // load the assembly
                try
                {
                    assembly = Assembly.Load(assembly_path);
                }
                catch (Exception)
                {
                    assembly = null;
                }

                if (assembly == null)
                {
                    try
                    {
                        assembly = Assembly.LoadFrom(assembly_path);
                    }
                    catch (Exception e)
                    {
                        LogLoadException(e, false, options.AssemblyFilePath);
                    }
                }

                if (assembly != null)
                {
                    Generate();
                }
            }
            finally
            {
                IDisposable disp = logPrinter as IDisposable;
                if (disp != null)
                {
                    disp.Dispose();
                }

                disp = codePrinter as IDisposable;
                if (disp != null)
                {
                    disp.Dispose();
                }
            }

#if DEBUG
            // wait for Enter only if we run under VS
            if (Process.GetCurrentProcess().MainModule.ModuleName.Contains("vshost"))
            {
                Console.ReadLine();
            }
#endif
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            options = new CommandLineOptions(args);

            // code will go to standard output
            if (options.UseColorConsoleOutput)
            {
                var console_printer = new ConsolePrinter();
                codePrinter = console_printer;
                logPrinter = console_printer; // ConsolePrinter writes log to stderr
            }
            else
            {
                codePrinter = new TextWriterPrinter(Console.Out);
                logPrinter = new TextWriterPrinter(Console.Error);
            }

            try
            {
                string assembly_path = options.AssemblyFilePath;
                Debug.Assert(!String.IsNullOrEmpty(assembly_path));

                // load the assembly
                try
                {
                    assembly = Assembly.Load(assembly_path);
                }
                catch (Exception)
                {
                    assembly = null;
                }

                if (assembly == null)
                {
                    try
                    {
                        assembly = Assembly.LoadFrom(assembly_path);
                    }
                    catch (Exception e)
                    {
                        LogLoadException(e, false, options.AssemblyFilePath);
                    }
                }

                if (assembly != null)
                {
                    Generate();
                }
            }
            finally
            {
                IDisposable disp = logPrinter as IDisposable;
                if (disp != null) disp.Dispose();

                disp = codePrinter as IDisposable;
                if (disp != null) disp.Dispose();
            }

            #if DEBUG
            // wait for Enter only if we run under VS
            if (Process.GetCurrentProcess().MainModule.ModuleName.Contains("vshost"))
            {
                Console.ReadLine();
            }
            #endif
        }