Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1660


Ignore:
Timestamp:
04/24/09 15:58:19 (15 years ago)
Author:
epitzer
Message:

Display a MessageBox if persistence application settings are corrupted. (#548)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence.GUI/3.3/PersistenceConfigurationForm.cs

    r1658 r1660  
    3434      InitializeNameTables();
    3535      initializeConfigPages();
    36       UpdateFromConfigurationService();
     36      try {
     37        ConfigurationService.Instance.LoadSettings(true);
     38        UpdateFromConfigurationService();
     39      } catch (PersistenceException e) {
     40        MessageBox.Show(
     41          "Persistence settings could not be loaded.\r\n" +
     42          "Default configurations will be used instead.",
     43          "Loading Settings Failed",
     44          MessageBoxButtons.OK,
     45          MessageBoxIcon.Information);
     46      }
    3747      underConstruction = false;
    3848      UpdatePreview();
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs

    r1654 r1660  
    3737    }
    3838
    39     protected void LoadSettings() {
     39    public void LoadSettings() {
     40      LoadSettings(false);
     41    }
     42
     43    public void LoadSettings(bool throwOnError) {
    4044      try {
    41         if (String.IsNullOrEmpty(Properties.Settings.Default.CustomConfigurations) ||
     45        TryLoadSettings();
     46      } catch (Exception e) {
     47        if (throwOnError) {
     48          throw new PersistenceException("Could not load persistence settings.", e);
     49        } else {
     50          Logger.Warn("Could not load settings.", e);
     51        }
     52      }     
     53    }
     54
     55    protected void TryLoadSettings() {
     56      if (String.IsNullOrEmpty(Properties.Settings.Default.CustomConfigurations) ||
    4257          String.IsNullOrEmpty(Properties.Settings.Default.CustomConfigurationsTypeCache))
    43           return;
    44         Deserializer deSerializer = new Deserializer(
    45           XmlParser.ParseTypeCache(
    46           new StringReader(
    47             Properties.Settings.Default.CustomConfigurationsTypeCache)));
    48         XmlParser parser = new XmlParser(
    49           new StringReader(
    50             Properties.Settings.Default.CustomConfigurations));
    51         var newCustomConfigurations = (Dictionary<IFormat, Configuration>)
    52           deSerializer.Deserialize(parser);
    53         foreach (var config in newCustomConfigurations) {
    54           customConfigurations[config.Key] = config.Value;
    55         }
    56       } catch (Exception e) {
    57         Logger.Warn("Could not load settings.", e);
     58        return;
     59      Deserializer deSerializer = new Deserializer(
     60        XmlParser.ParseTypeCache(
     61        new StringReader(
     62          Properties.Settings.Default.CustomConfigurationsTypeCache)));
     63      XmlParser parser = new XmlParser(
     64        new StringReader(
     65          Properties.Settings.Default.CustomConfigurations));
     66      var newCustomConfigurations = (Dictionary<IFormat, Configuration>)
     67        deSerializer.Deserialize(parser);
     68      foreach (var config in newCustomConfigurations) {
     69        customConfigurations[config.Key] = config.Value;
    5870      }
    5971    }
Note: See TracChangeset for help on using the changeset viewer.