Init() публичный статический Метод

public static Init ( string args, string engine ) : void
args string
engine string
Результат void
Пример #1
0
        public static void Main(string[] args)
        {
            bool debug = false;

            foreach (string arg in args)
            {
                switch (arg)
                {
                case "-d":
                case "--debug":
                    debug = true;
                    break;

                case "-h":
                case "--help":
                    ShowHelp();
                    Environment.Exit(0);
                    break;

                    /*
                     * // don't block other parameters as we pass them to
                     * // GTK+ / GNOME too
                     * default:
                     *  Console.WriteLine("Invalid option: " + arg);
                     *  Environment.Exit(1);
                     *  break;
                     */
                }
            }

#if LOG4NET
            // initialize log level
            log4net.Repository.ILoggerRepository repo = log4net.LogManager.GetRepository();
            if (debug)
            {
                repo.Threshold = log4net.Core.Level.Debug;
            }
            else
            {
                repo.Threshold = log4net.Core.Level.Info;
            }
#endif

            try {
                Frontend.Init(args);
            } catch (Exception e) {
#if LOG4NET
                _Logger.Fatal(e);
#endif
                // when Gtk# receives an exception it is not usable/relyable anymore!
                // except the exception was thrown in Frontend.Init() itself
                if (Frontend.IsGtkInitialized && !Frontend.InGtkApplicationRun)
                {
                    Frontend.ShowException(e);
                }

                // rethrow the exception for console output
                throw;
            }
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var debug       = false;
            var link        = String.Empty;
            var engine      = String.Empty;
            var newInstance = false;
            var options     = new OptionSet();

            options.Add(
                "d|debug",
                _("Enable debug output"),
                v => {
                debug = true;
            }
                );
            options.Add(
                "h|help",
                _("Show this help"),
                v => {
                Console.WriteLine("Usage: smuxi-frontend-gnome [options]");
                Console.WriteLine();
                Console.WriteLine(_("Options:"));
                options.WriteOptionDescriptions(Console.Out);
                Environment.Exit(0);
            }
                );
            options.Add(
                "e|engine=",
                _("Connect to engine"),
                v => {
                engine = v;
            }
                );
            options.Add(
                "open|open-link=",
                _("Opens the specified link in Smuxi"),
                v => {
                link = v;
            }
                );
            options.Add(
                "new-instance",
                _("Starts a new Smuxi instance and ignores an existing one"),
                v => {
                newInstance = true;
            }
                );

            try {
                options.Parse(args);

#if LOG4NET
                // initialize log level
                log4net.Repository.ILoggerRepository repo = log4net.LogManager.GetRepository();
                if (debug)
                {
                    repo.Threshold = log4net.Core.Level.Debug;
                }
                else
                {
                    repo.Threshold = log4net.Core.Level.Info;
                }
#endif

                try {
                    Instance = new SingleApplicationInstance <CommandLineInterface>();
                    if (Instance.IsFirstInstance)
                    {
                        Instance.FirstInstance = new CommandLineInterface();
                        if (!String.IsNullOrEmpty(link))
                        {
                            Instance.FirstInstance.OpenLink(link);
                        }
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(link))
                        {
                            var msg = _("Passing link to already running Smuxi instance...");
#if LOG4NET
                            _Logger.Info(msg);
#else
                            Console.WriteLine(msg);
#endif
                            Instance.FirstInstance.OpenLink(link);
                        }
                        else if (!newInstance)
                        {
                            var msg = _("Bringing already running Smuxi instance to foreground...");
#if LOG4NET
                            _Logger.Info(msg);
#else
                            Console.WriteLine(msg);
#endif
                            Instance.FirstInstance.PresentMainWindow();
                        }

                        if (!newInstance)
                        {
                            // don't initialize/spawn another instance
                            return;
                        }
                    }
                } catch (Exception ex) {
#if LOG4NET
                    _Logger.Warn("Single application instance error, ignoring...", ex);
#endif
                }

                Frontend.Init(args, engine);
            } catch (Exception e) {
#if LOG4NET
                _Logger.Fatal(e);
#endif
                // when Gtk# receives an exception it is not usable/relyable anymore!
                // except the exception was thrown in Frontend.Init() itself
                if (Frontend.IsGtkInitialized && !Frontend.InGtkApplicationRun)
                {
                    Frontend.ShowException(e);
                }

                // rethrow the exception for console output
                throw;
            }
        }