Index: /branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/app.config
===================================================================
--- /branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/app.config (revision 1405)
+++ /branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/app.config (revision 1406)
@@ -1,3 +1,18 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /branches/New Persistence Exploration/Persistence/Persistence/Core/Configuration.cs
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/Core/Configuration.cs (revision 1405)
+++ /branches/New Persistence Exploration/Persistence/Persistence/Core/Configuration.cs (revision 1406)
@@ -1,4 +1,3 @@
using System;
-using System.Collections;
using System.Collections.Generic;
using HeuristicLab.Persistence.Interfaces;
@@ -8,8 +7,13 @@
public class Configuration {
+ [Storable]
private readonly Dictionary formatters;
+ [Storable]
private readonly List decomposers;
private readonly Dictionary decomposerCache;
+ [Storable]
public readonly IFormat Format;
+
+ private Configuration() {}
public Configuration(Dictionary formatters, IEnumerable decomposers) {
@@ -27,5 +31,5 @@
}
- public IEnumerable Formatters {
+ public IEnumerable Formatters {
get { return formatters.Values; }
}
Index: /branches/New Persistence Exploration/Persistence/Persistence/Core/ConfigurationService.cs
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/Core/ConfigurationService.cs (revision 1405)
+++ /branches/New Persistence Exploration/Persistence/Persistence/Core/ConfigurationService.cs (revision 1406)
@@ -1,5 +1,10 @@
using System;
+using System.Collections.Specialized;
+using System.IO;
+using System.Linq;
using System.Collections.Generic;
using System.Reflection;
+using System.Text;
+using HeuristicLab.Persistence.Default.Xml;
using HeuristicLab.Persistence.Interfaces;
@@ -9,5 +14,5 @@
private static ConfigurationService instance;
- private Dictionary customConfigurations;
+ private readonly Dictionary customConfigurations;
public readonly Dictionary> Formatters;
public readonly List Decomposers;
@@ -24,10 +29,51 @@
Formatters = new Dictionary>();
Decomposers = new List();
- customConfigurations = new Dictionary();
+ customConfigurations = new Dictionary();
Reset();
+ LoadSettings();
+ }
+
+ public void LoadSettings() {
+ if ( String.IsNullOrEmpty(Properties.Settings.Default.customConfigurations) ||
+ String.IsNullOrEmpty(Properties.Settings.Default.customConfigurationsTypeCache) )
+ return;
+ DeSerializer deSerializer = new DeSerializer(
+ XmlParser.ParseTypeCache(
+ new StringReader(
+ Properties.Settings.Default.customConfigurationsTypeCache)));
+ XmlParser parser = new XmlParser(
+ new StringReader(
+ Properties.Settings.Default.customConfigurations));
+ var newCustomConfigurations = (Dictionary)
+ deSerializer.DeSerialize(parser);
+ foreach ( var config in newCustomConfigurations ) {
+ customConfigurations[config.Key] = config.Value;
+ }
+ }
+
+ public void SaveSettings() {
+ Serializer serializer = new Serializer(
+ customConfigurations,
+ GetDefaultConfig(XmlFormat.Instance),
+ "CustomConfigurations");
+ XmlGenerator generator = new XmlGenerator();
+ StringBuilder configurationString = new StringBuilder();
+ foreach (ISerializationToken token in serializer) {
+ configurationString.Append(generator.Format(token));
+ }
+ StringBuilder configurationTypeCacheString = new StringBuilder();
+ foreach (string s in generator.Format(serializer.TypeCache))
+ configurationTypeCacheString.Append(s);
+ Properties.Settings.Default.customConfigurations =
+ configurationString.ToString();
+ Properties.Settings.Default.customConfigurationsTypeCache =
+ configurationTypeCacheString.ToString();
+ Properties.Settings.Default.Save();
}
public void Reset() {
customConfigurations.Clear();
+ Formatters.Clear();
+ Decomposers.Clear();
Assembly defaultAssembly = Assembly.GetExecutingAssembly();
DiscoverFrom(defaultAssembly);
@@ -77,4 +123,5 @@
public void DefineConfiguration(IFormat format, Configuration configuration) {
customConfigurations[format] = configuration;
+ SaveSettings();
}
Index: /branches/New Persistence Exploration/Persistence/Persistence/HeuristicLab.Persistence.csproj
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/HeuristicLab.Persistence.csproj (revision 1405)
+++ /branches/New Persistence Exploration/Persistence/Persistence/HeuristicLab.Persistence.csproj (revision 1406)
@@ -45,4 +45,5 @@
+
3.5
@@ -60,4 +61,5 @@
+
@@ -81,4 +83,9 @@
+
+ True
+ True
+ Settings.settings
+
@@ -97,5 +104,10 @@
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+