예제 #1
0
파일: Program.cs 프로젝트: TeoTwawki/DFOCP
        private static int Run( string[] args )
        {
            if ( !RunningOn35Sp1OrBetter() )
            {
                EnsureConsoleExists();
                Logging.Log.FatalFormat( "Not running on .NET 3.5 SP1 or better. .NET 3.5 SP1 or better is required. Exiting." );
                Console.WriteLine( "Press enter to exit." );
                Console.ReadLine();
                return 1;
            }
            else
            {
                Logging.Log.DebugFormat( ".NET 3.5 SP1 or better detected." );
            }

            Logging.Log.Info( "Parsing command-line arguments." );

            CommandLineArgs parsedArgs = null;
            try
            {
                parsedArgs = new CommandLineArgs( args );
            }
            catch ( OptionException ex )
            {
                EnsureConsoleExists();
                Logging.Log.FatalFormat("Improper value for {0}: {1}", ex.OptionName, ex.Message );
                Logging.Log.FatalFormat( "Try {0} --help for more information.", CommandLineArgs.GetProgramName() );

                return 1;
            }

            Logging.Log.InfoFormat( "Command line parsed. Argument dump:{0}{1}", Environment.NewLine, parsedArgs );

            if ( !parsedArgs.Gui )
            {
                EnsureConsoleExists();
            }

            foreach ( string message in parsedArgs.Messages )
            {
                Logging.Log.Warn( message );
                // Doing the log in the arg handler and a Console.WriteLine here causes anything written
                // to the console to not show up, wtf?
            }

            if ( parsedArgs.Gui )
            {
                Logging.Log.Info( "Starting GUI." );
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault( false );
                Application.Run( new ctlMainForm( parsedArgs ) );
                return Environment.ExitCode;
            }
            else
            {
                Logging.Log.Info( "Starting command-line launcher." );

                using ( CommandLineEntryPoint cmd = new CommandLineEntryPoint( parsedArgs ) )
                {
                    return cmd.Run();
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: LHCGreg/DFOCP
        private static int Run(string[] args)
        {
            if (!RunningOn35Sp1OrBetter())
            {
                EnsureConsoleExists();
                Logging.Log.FatalFormat("Not running on .NET 3.5 SP1 or better. .NET 3.5 SP1 or better is required. Exiting.");
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();
                return(1);
            }
            else
            {
                Logging.Log.DebugFormat(".NET 3.5 SP1 or better detected.");
            }

            Logging.Log.Info("Parsing command-line arguments.");

            CommandLineArgs parsedArgs = null;

            try
            {
                parsedArgs = new CommandLineArgs(args);
            }
            catch (OptionException ex)
            {
                EnsureConsoleExists();
                Logging.Log.FatalFormat("Improper value for {0}: {1}", ex.OptionName, ex.Message);
                Logging.Log.FatalFormat("Try {0} --help for more information.", CommandLineArgs.GetProgramName());

                return(1);
            }

            Logging.Log.InfoFormat("Command line parsed. Argument dump:{0}{1}", Environment.NewLine, parsedArgs);

            if (!parsedArgs.Gui)
            {
                EnsureConsoleExists();
            }

            foreach (string message in parsedArgs.Messages)
            {
                Logging.Log.Warn(message);
                // Doing the log in the arg handler and a Console.WriteLine here causes anything written
                // to the console to not show up, wtf?
            }

            if (parsedArgs.Gui)
            {
                Logging.Log.Info("Starting GUI.");
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new ctlMainForm(parsedArgs));
                return(Environment.ExitCode);
            }
            else
            {
                Logging.Log.Info("Starting command-line launcher.");

                using (CommandLineEntryPoint cmd = new CommandLineEntryPoint(parsedArgs))
                {
                    return(cmd.Run());
                }
            }
        }