public bool CanExecute(object parameter) { try { return(InnerCanExecute(parameter)); } catch (Exception ex) { uiService.ShowError(ex, string.Format(CultureInfo.CurrentCulture, "An error occurred while determining if the command {0} can execute:", Title)); } return(false); }
private void LoadSectionsFromSource(IDesignConfigurationSource sectionConfigurationSource) { var locator = builder.Resolve <ConfigurationSectionLocator>(); foreach (var sectionName in locator.ConfigurationSectionNames) { try { var section = sectionConfigurationSource.GetLocalSection(sectionName); if (section != null) { AddSection(sectionName, section, new InitializeContext(sectionConfigurationSource)); } } catch (Exception e) { uiService.ShowError(e, string.Format(CultureInfo.CurrentCulture, Resources.ErrorCouldNotLoadSection, sectionName)); } } }
public bool SaveMainConfiguration(string fileName, bool saveAs) { try { if (!sourceModel.IsValidForSave() || !EnvironmentsCanSave()) { uiService.ShowError(Resources.SaveConfigurationInvalidError); return(false); } if (String.IsNullOrEmpty(fileName)) { return(SaveAs()); } if (!EnsureCanSaveConfigurationFile(fileName)) { return(false); } if (saveAs && !string.IsNullOrEmpty(this.configurationFileName) && File.Exists(this.configurationFileName)) { File.Copy(this.configurationFileName, fileName, true); // make the target file writable (it may have inherited the read-only attribute from the original file) FileAttributes attributes = File.GetAttributes(fileName); File.SetAttributes(fileName, attributes & ~FileAttributes.ReadOnly); } using (var configurationSource = new DesignConfigurationSource(fileName)) { var saved = sourceModel.Save(configurationSource); if (!saved) { return(false); } } ConfigurationFilePath = fileName; return(true); } catch (Exception ex) { ConfigurationLogWriter.LogException(ex); uiService.ShowMessageWpf(string.Format(CultureInfo.CurrentCulture, Resources.SaveApplicationErrorMessage, ex.Message), Resources.SaveApplicationErrorMessageTitle, MessageBoxButton.OK); return(false); } }