protected override void InnerExecute(object parameter) { OpenFileDialog openEnvironmentConfigurationDeltaDialog = new OpenFileDialog { Filter = DesignResources.DeltaDialogFilter, Title = DesignResources.OpenDeltaDialogTitle }; var openFileResult = UIService.ShowFileDialog(openEnvironmentConfigurationDeltaDialog); if (openFileResult.DialogResult != true) { return; } try { var configuration = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = openFileResult.FileName }, ConfigurationUserLevel.None); EnvironmentalOverridesSection mergeSection = (EnvironmentalOverridesSection)configuration.GetSection(EnvironmentalOverridesSection.EnvironmentallyOverriddenProperties); sourceModel.LoadEnvironment(mergeSection, openFileResult.FileName); } catch (Exception ex) { ConfigurationLogWriter.LogException(ex); UIService.ShowMessageWpf(string.Format(CultureInfo.CurrentCulture, Resources.ErrorLoadingDeltaFile, ex.Message), Resources.ErrorTitle, MessageBoxButton.OK); } }
private void UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { ConfigurationLogWriter.LogException(e.Exception); MessageBox.Show(string.Format(CultureInfo.CurrentCulture, Console.Properties.Resources.UnhandledExceptionMessageFormat, e.Exception.Message), Console.Properties.Resources.UnhandledExceptionMessageTitle, MessageBoxButton.OK, MessageBoxImage.Error); this.Shutdown(ExitWithFailureCode); }
public bool Load(IDesignConfigurationSource configSource) { Clear(); Initialize(); IDesignConfigurationSource sectionConfigurationSource = null; try { sectionConfigurationSource = GetSectionSource(configSource); } catch (Exception ex) { ConfigurationLogWriter.LogException(ex); uiService.ShowMessageWpf(string.Format(CultureInfo.CurrentCulture, Resources.ErrorLoadingConfigSourceFile, ex.Message), Resources.ErrorTitle, MessageBoxButton.OK); return(false); } if (sectionConfigurationSource != null) { try { AddSection(ConfigurationSourceSection.SectionName, configSource.GetLocalSection(ConfigurationSourceSection.SectionName), new InitializeContext(configSource)); LoadSectionsFromSource(sectionConfigurationSource); } catch { var disposable = sectionConfigurationSource as IDisposable; if (disposable != null) { disposable.Dispose(); } throw; } } else { LoadSectionsFromSource(configSource); } Validate(); return(true); }
public bool Save(IDesignConfigurationSource configurationSource) { saveOperation.BeginPerformSaveOperation(); try { var sectionsToSave = Sections.Where(x => null == x as EnvironmentSourceViewModel); var sectionSaveSource = GetSectionSourceFromModel(configurationSource); if (sectionSaveSource != null) { try { try { SaveConfigurationSource(configurationSource); } catch (Exception e) { ConfigurationLogWriter.LogException(e); uiService.ShowError(e, Resources.ErrorSavingConfigurationSourceOnMainFile); return(false); } try { SaveSections( sectionsToSave.Where( x => !typeof(ConfigurationSourceSection).IsAssignableFrom(x.ConfigurationType)), sectionSaveSource); } catch (Exception e) { ConfigurationLogWriter.LogException(e); uiService.ShowError(e, Resources.ErrorSavingConfigurationSectionsOnSelectedSource); return(false); } return(true); } finally { var disposable = sectionSaveSource as IDisposable; if (disposable != null) { disposable.Dispose(); } } } try { SaveSections(sectionsToSave, configurationSource); } catch (Exception e) { ConfigurationLogWriter.LogException(e); uiService.ShowError(e, Resources.ErrorSavingConfigurationSectionsOnMainFile); return(false); } } finally { saveOperation.EndPerformSaveOperation(); } return(true); }