Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1418


Ignore:
Timestamp:
03/25/09 17:15:42 (16 years ago)
Author:
epitzer
Message:

Don't crash if user configuration cannot be loaded. (#506)

Location:
branches/New Persistence Exploration/Persistence/Persistence/Core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/New Persistence Exploration/Persistence/Persistence/Core/Configuration.cs

    r1406 r1418  
    1515    public readonly IFormat Format;
    1616
    17     private Configuration() {}
     17    private Configuration() {
     18      decomposerCache = new Dictionary<Type, IDecomposer>();
     19    }
    1820
    1921    public Configuration(Dictionary<Type, IFormatter> formatters, IEnumerable<IDecomposer> decomposers) {     
  • branches/New Persistence Exploration/Persistence/Persistence/Core/ConfigurationService.cs

    r1406 r1418  
    3535
    3636    public void LoadSettings() {
    37       if ( String.IsNullOrEmpty(Properties.Settings.Default.customConfigurations) ||
    38         String.IsNullOrEmpty(Properties.Settings.Default.customConfigurationsTypeCache) )
    39         return;
    40       DeSerializer deSerializer = new DeSerializer(
    41         XmlParser.ParseTypeCache(
    42         new StringReader(
    43           Properties.Settings.Default.customConfigurationsTypeCache)));
    44       XmlParser parser = new XmlParser(
    45         new StringReader(
    46           Properties.Settings.Default.customConfigurations));
    47       var newCustomConfigurations = (Dictionary<IFormat, Configuration>)
    48         deSerializer.DeSerialize(parser);     
    49       foreach ( var config in newCustomConfigurations ) {
    50         customConfigurations[config.Key] = config.Value;
     37      try {
     38        if (String.IsNullOrEmpty(Properties.Settings.Default.customConfigurations) ||
     39          String.IsNullOrEmpty(Properties.Settings.Default.customConfigurationsTypeCache))
     40          return;
     41        DeSerializer deSerializer = new DeSerializer(
     42          XmlParser.ParseTypeCache(
     43          new StringReader(
     44            Properties.Settings.Default.customConfigurationsTypeCache)));
     45        XmlParser parser = new XmlParser(
     46          new StringReader(
     47            Properties.Settings.Default.customConfigurations));
     48        var newCustomConfigurations = (Dictionary<IFormat, Configuration>)
     49          deSerializer.DeSerialize(parser);
     50        foreach (var config in newCustomConfigurations) {
     51          customConfigurations[config.Key] = config.Value;
     52        }
     53      } catch {
     54        Console.WriteLine("WARNING: Could not load settings.");
    5155      }
    5256    }
Note: See TracChangeset for help on using the changeset viewer.