Ejemplo n.º 1
0
        private OptionsForm(bool local)
        {
            InitializeComponent();
            
            // Copy the Bootstrap.exe file to New.exe,
            // so that the configuration file will load properly
            string currentDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            string sandboxDir = Path.Combine(currentDir, "Sandbox");

            if (!File.Exists(Path.Combine(sandboxDir, "New.exe")))
            {
                File.Copy(
                    Path.Combine(sandboxDir, "Bootstrap.exe"),
                    Path.Combine(sandboxDir, "New.exe")
                );
            }

            string filename = local ? "New.exe" : "Bootstrap.exe";
            string filepath = Path.Combine(sandboxDir, filename);
            _Configuration = ConfigurationManager.OpenExeConfiguration(filepath);
            
            // Get the DDay.Update configuration section
            _Cfg = _Configuration.GetSection("DDay.Update") as DDayUpdateConfigurationSection;

            // Set the default setting on which application folder to use.
            cbAppFolder.SelectedIndex = 0;

            SetValuesFromConfig();

            if (!local)
                _Configuration.SaveAs(Path.Combine(sandboxDir, "New.exe.config"));
        }
Ejemplo n.º 2
0
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            // Get the DDay.Update configuration section
            cfg = ConfigurationManager.GetSection("DDay.Update")
                as DDayUpdateConfigurationSection;

            string command = "";

            string[] args = GetArgs();

            //check if update arg has been passed
            if (args.Length > 0)
            {
                //check if first arg is a command
                if (args[0].StartsWith("-"))
                {
                    //if it is then assign it
                    command = args[0];
                    //and remove first arg
                    string[] newargs = new string[args.Length - 1];
                    Array.Copy(args, 1, newargs, 0, args.Length - 1);
                    //assign new args
                    args = newargs;
                }
            }

            // Set the command line parameters to the application
            UpdateManager.SetCommandLineParameters(args);

            if (command == "-updatelaunch" || cfg.Automatic)
            {
                Update();
                Launch();
            }
            else if (command == "-update")
            {
                Update();
            }
            else if (command == "-remove")
            {
                Remove();
            }
            else
            {
                Launch();
            }

            log.Debug("Exiting bootstrap application...");
        }