Esempio n. 1
0
        public SettingsFixture()
        {
            if (settings == null)
            {
                // Assembly.GetEntryAssembly() is null for tests wihtout GUI runner so filling it in to prevent null object exceptions
                Settings.EntryAssembly = Assembly.GetExecutingAssembly();

                settings = new MemoryStream();
                Settings.SaveCustomSettings(settings, false);
            }
        }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            // Validate user provide settings
            if (string.IsNullOrEmpty(this.uiProviderComboBox.Text))
            {
                MessageBox.Show(
                    "The 'User Interface > UI Provider' selection should not be left blank. Please select a value for the provider or set the UI Mode to Auto.",
                    "User Interface Provider is Left Blank",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                this.uiProviderComboBox.Focus();
                return;
            }

            Settings.EnableNetworkTrace = this.writeNetworkTraceToFileCheckBox.Checked;             // This should come before settings app config

            // Save application settings
            Settings.UIMode             = (UIMode)this.uiModeComboBox.SelectedItem;
            Settings.UIProvider         = (UIProvider)this.uiProviderComboBox.SelectedItem;
            Settings.MiniDumpType       = (MiniDumpType)this.miniDumpTypeComboBox.SelectedItem;
            Settings.SleepBeforeSend    = Convert.ToInt32(this.sleepBeforeSendNumericUpDown.Value);
            Settings.MaxQueuedReports   = Convert.ToInt32(this.maxQueuedReportsNumericUpDown.Value);
            Settings.StopReportingAfter = Convert.ToInt32(this.stopReportingAfterNumericUpDown.Value);
            Settings.WriteLogToDisk     = this.writeLogToDiskCheckBox.Checked;
            Settings.HandleProcessCorruptedStateExceptions = this.handleProcessCorruptedStateExceptionsCheckBox.Checked;
            Settings.ReleaseMode = this.releaseModeCheckBox.Checked;

            if ((UIMode)this.uiModeComboBox.SelectedItem == UIMode.None)
            {
                Settings.ExitApplicationImmediately = this.exitApplicationImmediatelyCheckBox.Checked;
            }

            Settings.StoragePath = this.storagePathComboBox.Text == "Custom" ? this.customStoragePathTextBox.Text : this.storagePathComboBox.Text;

            Settings.Destinations.Clear();

            // Save connection strings
            foreach (
                var connectionString in
                this.panelLoaders.Where(p => p.Controls.Count == 2)
                .Select(p => ((ISubmitPanel)p.Controls[0]).ConnectionString)
                .Where(s => !string.IsNullOrEmpty(s)))
            {
                Settings.AddDestinationFromConnectionString(connectionString);
            }

            this.settingsFile.Position = 0;
            SettingsOverride.SaveCustomSettings(this.settingsFile, this.encryptConnectionStringsCheckBox.Checked);
            this.status.Text = "Configuration file successfully saved. Please test your configuration.";
        }