Index: /trunk/sources/HeuristicLab.Persistence/3.3/Core/Configuration.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Core/Configuration.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Core/Configuration.cs	(revision 1564)
@@ -9,9 +9,11 @@
     [Storable]
     private readonly Dictionary<Type, IFormatter> formatters;
+
     [Storable]
     private readonly List<IDecomposer> decomposers;
     private readonly Dictionary<Type, IDecomposer> decomposerCache;
-    [Storable]
-    public IFormat Format { get; set; }
+
+    [Storable]    
+    public IFormat Format { get; private set; }
 
     private Configuration() {
@@ -19,10 +21,9 @@
     }
 
-    public Configuration(Dictionary<Type, IFormatter> formatters, IEnumerable<IDecomposer> decomposers) {      
+    public Configuration(IFormat format, Dictionary<Type, IFormatter> formatters, IEnumerable<IDecomposer> decomposers) {
+      this.Format = format;
       this.formatters = new Dictionary<Type, IFormatter>();
       foreach ( var pair in formatters ) {
-        if (Format == null) {
-          Format = pair.Value.Format;
-        } else if (pair.Value.Format != Format ) {
+        if (pair.Value.SerialDataType != format.SerialDataType ) {
           throw new ArgumentException("All formatters must have the same IFormat.");
         }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs	(revision 1564)
@@ -15,6 +15,7 @@
     private static ConfigurationService instance;
     private readonly Dictionary<IFormat, Configuration> customConfigurations;
-    public Dictionary<IFormat, List<IFormatter>> Formatters { get; private set; }
+    public Dictionary<Type, List<IFormatter>> Formatters { get; private set; }
     public List<IDecomposer> Decomposers { get; private set; }
+    public List<IFormat> Formats { get; private set; }
     
     public static ConfigurationService Instance {
@@ -27,7 +28,8 @@
 
     private ConfigurationService() {
-      Formatters = new Dictionary<IFormat, List<IFormatter>>();
+      Formatters = new Dictionary<Type, List<IFormatter>>();
       Decomposers = new List<IDecomposer>();
-      customConfigurations = new Dictionary<IFormat, Configuration>();      
+      customConfigurations = new Dictionary<IFormat, Configuration>();
+      Formats = new List<IFormat>();
       Reset();
       LoadSettings();
@@ -59,5 +61,5 @@
       Serializer serializer = new Serializer(
         customConfigurations,
-        GetDefaultConfig(XmlFormat.Instance),
+        GetDefaultConfig(new XmlFormat()),
         "CustomConfigurations");
       XmlGenerator generator = new XmlGenerator();
@@ -103,9 +105,12 @@
           try {
             IFormatter formatter = (IFormatter) Activator.CreateInstance(t, true);
-            if ( ! Formatters.ContainsKey(formatter.Format) ) {
-              Formatters.Add(formatter.Format, new List<IFormatter>());
+            if ( ! Formatters.ContainsKey(formatter.SerialDataType) ) {
+              Formatters.Add(formatter.SerialDataType, new List<IFormatter>());
             }
-            Formatters[formatter.Format].Add(formatter);
-            Logger.Debug("discovered formatter " + t.VersionInvariantName());
+            Formatters[formatter.SerialDataType].Add(formatter);
+            Logger.Debug(String.Format("discovered formatter {0} ({1} -> {2})",
+              t.VersionInvariantName(),
+              formatter.SourceType.VersionInvariantName(),
+              formatter.SerialDataType.VersionInvariantName()));
           } catch (MissingMethodException e) {
             Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);            
@@ -124,4 +129,18 @@
           }
         }
+        if (t.GetInterface(typeof(IFormat).FullName) != null) {
+          try {
+            IFormat format = (IFormat)Activator.CreateInstance(t, true);
+            Formats.Add(format);
+            Logger.Debug(String.Format("discovered format {0} ({2}) with serial data {1}.",
+              format.Name,
+              format.SerialDataType,
+              t.VersionInvariantName()));              
+          } catch (MissingMethodException e) {
+            Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);          
+          } catch (ArgumentException e) {
+            Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);
+          }          
+        }
       }
     }
@@ -129,9 +148,9 @@
     public Configuration GetDefaultConfig(IFormat format) {
       Dictionary<Type, IFormatter> formatterConfig = new Dictionary<Type, IFormatter>();
-      foreach ( IFormatter f in Formatters[format] ) {
-        if ( ! formatterConfig.ContainsKey(f.Type) )
-          formatterConfig.Add(f.Type, f);
+      foreach ( IFormatter f in Formatters[format.SerialDataType] ) {
+        if ( ! formatterConfig.ContainsKey(f.SourceType) )
+          formatterConfig.Add(f.SourceType, f);
       }
-      return new Configuration(formatterConfig, Decomposers);
+      return new Configuration(format, formatterConfig, Decomposers);
     }
 
@@ -142,6 +161,6 @@
     }
 
-    public void DefineConfiguration(IFormat format, Configuration configuration) {
-      customConfigurations[format] = configuration;
+    public void DefineConfiguration(Configuration configuration) {      
+      customConfigurations[configuration.Format] = configuration;
       SaveSettings();
     }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Core/FormatBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Core/FormatBase.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Core/FormatBase.cs	(revision 1564)
@@ -3,17 +3,22 @@
 namespace HeuristicLab.Persistence.Interfaces {
 
-  public abstract class FormatBase : IFormat {
-    public abstract string Name { get;  }
+  public abstract class FormatBase<SerialDataFormat> : IFormat<SerialDataFormat> where SerialDataFormat : ISerialData {
+
+    public abstract string Name { get; }
+
+    public Type SerialDataType { get { return typeof(SerialDataFormat); } }
+
+    public bool Equals(FormatBase<SerialDataFormat> f) {
+      if (f == null)
+        return false;
+      return f.Name == this.Name;
+    }
+
     public override bool Equals(object obj) {
-      if (obj as IFormat == null)
-        return false;
-      return this.Equals((FormatBase)obj);      
+      FormatBase<SerialDataFormat> f = obj as FormatBase<SerialDataFormat>;      
+      return Equals(f);
     }
-    public bool Equals(FormatBase f) {
-      return Name.Equals(f.Name);
-    }
-    public override int GetHashCode() {
-      return Name.GetHashCode();
-    }
+    
   }
+
 }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Core/FormatterBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Core/FormatterBase.cs	(revision 1564)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Core/FormatterBase.cs	(revision 1564)
@@ -0,0 +1,25 @@
+﻿using System;
+
+namespace HeuristicLab.Persistence.Interfaces {
+  
+  public abstract class FormatterBase<Source, SerialData> : IFormatter<Source, SerialData> where SerialData : ISerialData {
+
+    public abstract SerialData Format(Source o);
+
+    public abstract Source Parse(SerialData t);
+
+    public Type SerialDataType { get { return typeof(SerialData); } }
+
+    public Type SourceType { get { return typeof(Source); } }
+
+    ISerialData IFormatter.Format(object o) {
+      return Format((Source)o);    
+    }
+
+    object IFormatter.Parse(ISerialData o) {
+      return Parse((SerialData)o);
+    }
+
+  }
+     
+}
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Core/GeneratorBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Core/GeneratorBase.cs	(revision 1564)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Core/GeneratorBase.cs	(revision 1564)
@@ -0,0 +1,41 @@
+﻿using System.Collections.Generic;
+using System;
+using System.Text;
+using HeuristicLab.Persistence.Interfaces;
+using HeuristicLab.Persistence.Core;
+using System.IO;
+using ICSharpCode.SharpZipLib.Zip;
+using HeuristicLab.Tracing;
+using log4net;
+using HeuristicLab.Persistence.Core.Tokens;
+
+namespace HeuristicLab.Persistence.Core {
+  
+  public abstract class GeneratorBase<T> {
+    public T Format(ISerializationToken token) {
+      Type type = token.GetType();
+      if (type == typeof(BeginToken))
+        return Format((BeginToken)token);
+      if (type == typeof(EndToken))
+        return Format((EndToken)token);
+      if (type == typeof(PrimitiveToken))
+        return Format((PrimitiveToken)token);
+      if (type == typeof(ReferenceToken))
+        return Format((ReferenceToken)token);
+      if (type == typeof(NullReferenceToken))
+        return Format((NullReferenceToken)token);
+      if (type == typeof(MetaInfoBeginToken))
+        return Format((MetaInfoBeginToken)token);
+      if (type == typeof(MetaInfoEndToken))
+        return Format((MetaInfoEndToken)token);
+      throw new ApplicationException("Invalid token of type " + type.FullName);
+    }
+    protected abstract T Format(BeginToken beginToken);
+    protected abstract T Format(EndToken endToken);
+    protected abstract T Format(PrimitiveToken primitiveToken);
+    protected abstract T Format(ReferenceToken referenceToken);
+    protected abstract T Format(NullReferenceToken nullReferenceToken);
+    protected abstract T Format(MetaInfoBeginToken metaInfoBeginToken);
+    protected abstract T Format(MetaInfoEndToken metaInfoEndToken);
+  }  
+}
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Core/Serializer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Core/Serializer.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Core/Serializer.cs	(revision 1564)
@@ -69,5 +69,5 @@
       IFormatter formatter = configuration.GetFormatter(value.GetType());
       if (formatter != null)
-        return PrimitiveEnumerator(accessor.Name, typeId, formatter.DoFormat(value), id);
+        return PrimitiveEnumerator(accessor.Name, typeId, formatter.Format(value), id);
       IDecomposer decomposer = configuration.GetDecomposer(value.GetType()); 
       if (decomposer != null)
@@ -88,5 +88,5 @@
 
     private IEnumerator<ISerializationToken> PrimitiveEnumerator(string name,
-        int typeId, object serializedValue, int? id) {
+        int typeId, ISerialData serializedValue, int? id) {
       yield return new PrimitiveToken(name, typeId, id, serializedValue);
     }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Core/Tokens/PrimitiveToken.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Core/Tokens/PrimitiveToken.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Core/Tokens/PrimitiveToken.cs	(revision 1564)
@@ -6,6 +6,6 @@
     public readonly int TypeId;
     public readonly int? Id;
-    public readonly object SerialData;
-    public PrimitiveToken(string name, int typeId, int? id, object serialData)
+    public readonly ISerialData SerialData;
+    public PrimitiveToken(string name, int typeId, int? id, ISerialData serialData)
       : base(name) {
       TypeId = typeId;
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/ViewOnly/ViewOnlyFormat.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/ViewOnly/ViewOnlyFormat.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/ViewOnly/ViewOnlyFormat.cs	(revision 1564)
@@ -9,47 +9,44 @@
 namespace HeuristicLab.Persistence.Default.ViewOnly {
 
-  public class ViewOnlyFormat : FormatBase {
-    public override string Name { get { return "ViewOnly"; } }
-    public static ViewOnlyFormat Instance = new ViewOnlyFormat();
+  public class String : ISerialData {
+    public string Data { get; set; }
+    public String(string s) {
+      Data = s;
+    }
   }
 
-  public abstract class ValueType2ViewFormatter : IFormatter {
-    public abstract Type Type { get; }
-    public IFormat Format { get { return ViewOnlyFormat.Instance; } }
-    public object DoFormat(object o) { return o; }
-    public object Parse(object o) {
+  public class ViewOnlyFormat : FormatBase<String> {
+    public override string Name { get { return "ViewOnly"; } }    
+  }
+
+  public abstract class ValueType2ViewFormatterBase<T> : FormatterBase<T, String> {
+    public override String Format(T o) { return new String(o.ToString()); }
+    public override T Parse(String s) {
       throw new NotImplementedException();
     }
   }
 
-  public class String2ViewFormatter : ValueType2ViewFormatter {
-    public override Type Type { get { return typeof(string); } }
-  }
+  [EmptyStorableClass]
+  public class String2ViewFormatter : ValueType2ViewFormatterBase<string> { }
 
-  public class Bool2ViewFormatter : ValueType2ViewFormatter {
-    public override Type Type { get { return typeof(bool); } }
-  }
+  [EmptyStorableClass]
+  public class Bool2ViewFormatter : ValueType2ViewFormatterBase<bool> { }
 
-  public class Int2ViewFormatter : ValueType2ViewFormatter {
-    public override Type Type { get { return typeof(int); } }
-  }
+  [EmptyStorableClass]
+  public class Int2ViewFormatter : ValueType2ViewFormatterBase<int> { }
 
-  public class Double2ViewFormatter : ValueType2ViewFormatter {
-    public override Type Type { get { return typeof(double); } }
-  }
+  [EmptyStorableClass]
+  public class Double2ViewFormatter : ValueType2ViewFormatterBase<double> { }
 
-  public class DateTime2ViewFormatter : ValueType2ViewFormatter {
-    public override Type Type { get { return typeof(DateTime); } }
-  }
+  [EmptyStorableClass]
+  public class DateTime2ViewFormatter : ValueType2ViewFormatterBase<DateTime> { }
 
-  public class Type2ViewFormatter : ValueType2ViewFormatter {
-    public override Type Type { get { return typeof(Type); } }
-  }
+  [EmptyStorableClass]
+  public class Type2ViewFormatter : ValueType2ViewFormatterBase<Type> { }
 
-  public class Float2ViewFormatter : ValueType2ViewFormatter {
-    public override Type Type { get { return typeof(float); } }
-  }
-
-  public class ViewOnlyGenerator : Generator<string> {
+  [EmptyStorableClass]
+  public class Float2ViewFormatter : ValueType2ViewFormatterBase<float> { }
+    
+  public class ViewOnlyGenerator : GeneratorBase<string> {
 
     private bool isSepReq;
@@ -98,5 +95,5 @@
         sb.Append('=');
       }
-      sb.Append(primitiveToken.SerialData);
+      sb.Append(((String)primitiveToken.SerialData).Data);
       isSepReq = true;      
       return sb.ToString();  
@@ -140,5 +137,5 @@
 
     public static string Serialize(object o) {
-      return Serialize(o, ConfigurationService.Instance.GetDefaultConfig(ViewOnlyFormat.Instance));
+      return Serialize(o, ConfigurationService.Instance.GetDefaultConfig(new ViewOnlyFormat()));
     }
 
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleArray2XmlFormatters.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleArray2XmlFormatters.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleArray2XmlFormatters.cs	(revision 1564)
@@ -4,14 +4,7 @@
 
 namespace HeuristicLab.Persistence.Default.Xml.Compact {
-
-  [EmptyStorableClass]
-  public class DoubleArray2XmlFormatter : NumberArray2XmlFormatterBase {
-
-    public override Type Type {
-      get {
-        return typeof(double[]);
-      }
-    }
-
+  
+  public abstract class DoubleArray2XmlFormatterBase<T> : NumberArray2XmlFormatterBase<T> {
+    
     protected override string FormatValue(object o) {
       return ((double)o).ToString("r", CultureInfo.InvariantCulture);
@@ -24,20 +17,12 @@
 
   [EmptyStorableClass]
-  public class Double2DArray2XmlFormatter : DoubleArray2XmlFormatter {
-    public override Type Type {
-      get {
-        return typeof(double[,]);
-      }
-    }
-  }
+  public class Double1DArray2XmlFormatter : DoubleArray2XmlFormatterBase<double[]> { }
+
 
   [EmptyStorableClass]
-  public class Double3DArray2XmlFormatter : DoubleArray2XmlFormatter {
-    public override Type Type {
-      get {
-        return typeof(double[, ,]);
-      }
-    }
-  }
+  public class Double2DArray2XmlFormatter : DoubleArray2XmlFormatterBase<double[,]> { }
+
+  [EmptyStorableClass]
+  public class Double3DArray2XmlFormatter : DoubleArray2XmlFormatterBase<double[,,]> { }
   
 }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleList2XmlFormatter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleList2XmlFormatter.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleList2XmlFormatter.cs	(revision 1564)
@@ -8,11 +8,5 @@
 
   [EmptyStorableClass]
-  public class DoubleList2XmlFormatter : NumberEnumeration2XmlFormatterBase {
-
-    public override Type Type {
-      get {
-        return typeof(List<double>);
-      }
-    }
+  public class DoubleList2XmlFormatter : NumberEnumeration2XmlFormatterBase<List<double>> {    
 
     protected override void Add(IEnumerable enumeration, object o) {
@@ -20,5 +14,5 @@
     }
 
-    protected override object Instantiate() {
+    protected override IEnumerable Instantiate() {
       return new List<double>();
     }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/IntArray2XmlFormatters.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/IntArray2XmlFormatters.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/IntArray2XmlFormatters.cs	(revision 1564)
@@ -3,13 +3,6 @@
 
 namespace HeuristicLab.Persistence.Default.Xml.Compact {
-
-  [EmptyStorableClass]
-  public class IntArray2XmlFormatter : NumberArray2XmlFormatterBase {
-
-    public override Type Type {
-      get {
-        return typeof(int[]);
-      }
-    }
+  
+  public abstract class IntArray2XmlFormatterBase<T> : NumberArray2XmlFormatterBase<T> {    
 
     protected override string FormatValue(object o) {
@@ -22,23 +15,12 @@
   }
 
+  [EmptyStorableClass]
+  public class Int1DArray2XmlFormatter : IntArray2XmlFormatterBase<int[]> { }
 
   [EmptyStorableClass]
-  public class Int2DArray2XmlFormatter : IntArray2XmlFormatter {
-    public override Type Type {
-      get {
-        return typeof(int[,]);
-      }
-    }
-  }
-
+  public class Int2DArray2XmlFormatter : IntArray2XmlFormatterBase<int[,]> { }
 
   [EmptyStorableClass]
-  public class Int3DArray2XmlFormatter : IntArray2XmlFormatter {
-    public override Type Type {
-      get {
-        return typeof(int[, ,]);
-      }
-    }
-  }
+  public class Int3DArray2XmlFormatter : IntArray2XmlFormatterBase<int[,,]> { }
   
 }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/IntList2XmlFormatter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/IntList2XmlFormatter.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/IntList2XmlFormatter.cs	(revision 1564)
@@ -7,17 +7,11 @@
 
   [EmptyStorableClass]
-  public class IntList2XmlFormatter : NumberEnumeration2XmlFormatterBase {
-
-    public override Type Type {
-      get {
-        return typeof(List<int>);
-      }
-    }
-
+  public class IntList2XmlFormatter : NumberEnumeration2XmlFormatterBase<List<int>> {
+    
     protected override void Add(IEnumerable enumeration, object o) {
       ((List<int>)enumeration).Add((int)o);
     }
 
-    protected override object Instantiate() {
+    protected override IEnumerable Instantiate() {
       return new List<int>();
     }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/NumberArray2XmlFormatterBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/NumberArray2XmlFormatterBase.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/NumberArray2XmlFormatterBase.cs	(revision 1564)
@@ -6,14 +6,13 @@
 namespace HeuristicLab.Persistence.Default.Xml.Compact {
                                                               
-  public abstract class NumberArray2XmlFormatterBase : IFormatter {
+  public abstract class NumberArray2XmlFormatterBase<T> : FormatterBase<T, XmlString> {
 
-    public abstract Type Type { get; }
-    public IFormat Format { get { return XmlFormat.Instance; } }
     protected virtual string Separator { get { return ";"; } }
     protected abstract string FormatValue(object o);
     protected abstract object ParseValue(string o);
 
-    public object DoFormat(object obj) {
-      Array a = (Array)obj;
+    public override XmlString Format(T t) {
+      object o = (object)t;
+      Array a = (Array)o;
       int[] lengths = new int[a.Rank];
       int[] lowerBounds = new int[a.Rank];
@@ -44,11 +43,10 @@
         }
       }      
-      return sb.ToString();
+      return new XmlString(sb.ToString());
     }
 
-    public object Parse(object o) {
+    public override T Parse(XmlString x) {
       IEnumerator values =
-        ((string)o)
-        .Split(new[] { Separator },
+        x.Data.Split(new[] { Separator },
         StringSplitOptions.RemoveEmptyEntries).GetEnumerator();
       values.MoveNext();
@@ -64,5 +62,5 @@
         lowerBounds[i] = int.Parse((string)values.Current);
       }
-      Array a = Array.CreateInstance(this.Type.GetElementType(), lengths, lowerBounds);
+      Array a = Array.CreateInstance(this.SourceType.GetElementType(), lengths, lowerBounds);
       int[] positions = new int[rank];
       while (values.MoveNext()) {
@@ -78,5 +76,6 @@
         }
       }
-      return a;
+      object o = a;
+      return (T)o;
     }
   }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/NumberEnumeration2XmlFormatterBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/NumberEnumeration2XmlFormatterBase.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/NumberEnumeration2XmlFormatterBase.cs	(revision 1564)
@@ -6,30 +6,28 @@
 namespace HeuristicLab.Persistence.Default.Xml.Compact {
   
-  public abstract class NumberEnumeration2XmlFormatterBase : IFormatter {
+  public abstract class NumberEnumeration2XmlFormatterBase<T> : FormatterBase<T, XmlString> where T : IEnumerable {
 
-    public abstract Type Type { get; }
-    public IFormat Format { get { return XmlFormat.Instance; } }
     protected virtual string Separator { get { return ";"; } }
     protected abstract void Add(IEnumerable enumeration, object o);
-    protected abstract object Instantiate();
+    protected abstract IEnumerable Instantiate();
     protected abstract string FormatValue(object o);
     protected abstract object ParseValue(string o);
 
-    public object DoFormat(object o) {
+    public override XmlString Format(T t) {
       StringBuilder sb = new StringBuilder();
-      foreach (var value in (IEnumerable)o) {
+      foreach (var value in (IEnumerable)t) {
         sb.Append(FormatValue(value));
         sb.Append(Separator);
       }
-      return sb.ToString();
+      return new XmlString(sb.ToString());
     }
 
-    public object Parse(object o) {
-      IEnumerable enumeration = (IEnumerable)Instantiate();
-      string[] values = ((string)o).Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries);
+    public override T Parse(XmlString x) {
+      IEnumerable enumeration = Instantiate();
+      string[] values = x.Data.Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries);
       foreach (var value in values) {
         Add(enumeration, ParseValue(value));
       }
-      return enumeration;
+      return (T)enumeration;
     }
   }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/DateTime2XmlFormatter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/DateTime2XmlFormatter.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/DateTime2XmlFormatter.cs	(revision 1564)
@@ -6,15 +6,12 @@
 
   [EmptyStorableClass]
-  public class DateTime2XmlFormatter : IFormatter {    
-
-    public Type Type { get { return typeof(DateTime); } }
-    public IFormat Format { get { return XmlFormat.Instance; } }  
-
-    public object DoFormat(object o) {
-      return ((DateTime)o).Ticks.ToString();      
+  public class DateTime2XmlFormatter : FormatterBase<DateTime, XmlString> {    
+    
+    public override XmlString Format(DateTime dt) {
+      return new XmlString(dt.Ticks.ToString());      
     }
 
-    public object Parse(object o) {
-      return new DateTime(long.Parse((string)o));
+    public override DateTime Parse(XmlString x) {
+      return new DateTime(long.Parse(x.Data));
     }
 
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/DecimalNumber2XmlFormatterBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/DecimalNumber2XmlFormatterBase.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/DecimalNumber2XmlFormatterBase.cs	(revision 1564)
@@ -7,10 +7,6 @@
 namespace HeuristicLab.Persistence.Default.Xml.Primitive {  
   
-  public abstract class DecimalNumber2XmlFormatterBase<T> : IFormatter {
-
-    public Type Type { get { return typeof(T); } }
-
-    public IFormat Format { get { return XmlFormat.Instance; } }
-
+  public abstract class DecimalNumber2XmlFormatterBase<T> : FormatterBase<T, XmlString> {
+    
     private static MethodInfo ToStringMethod = typeof(T)
       .GetMethod(
@@ -31,9 +27,9 @@
         null);
 
-    public object DoFormat(object o) {
-      return ToStringMethod.Invoke(o, new object[] { "r", CultureInfo.InvariantCulture });
+    public override XmlString Format(T t) {
+      return new XmlString((string)ToStringMethod.Invoke(t, new object[] { "r", CultureInfo.InvariantCulture }));
     }
-    public object Parse(object o) {      
-      return ParseMethod.Invoke(null, new[] { o, CultureInfo.InvariantCulture });
+    public override T Parse(XmlString x) {      
+      return (T)ParseMethod.Invoke(null, new object[] { x.Data, CultureInfo.InvariantCulture });
     }
   }  
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/SimpleNumber2XmlFormatterBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/SimpleNumber2XmlFormatterBase.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/SimpleNumber2XmlFormatterBase.cs	(revision 1564)
@@ -7,9 +7,5 @@
 namespace HeuristicLab.Persistence.Default.Xml.Primitive {  
 
-  public abstract class SimpleNumber2XmlFormatterBase<T> : IFormatter {
-
-    public Type Type { get { return typeof(T); } }
-
-    public IFormat Format { get { return XmlFormat.Instance; } }
+  public abstract class SimpleNumber2XmlFormatterBase<T> : FormatterBase<T, XmlString> {
 
     private static MethodInfo ParseMethod = typeof(T)
@@ -22,9 +18,9 @@
         null);
 
-    public object DoFormat(object o) {
-      return ((T)o).ToString();
+    public override XmlString Format(T t) {
+      return new XmlString(t.ToString());
     }
-    public object Parse(object o) {
-      return ParseMethod.Invoke(null, new[] { o });      
+    public override T Parse(XmlString x) {
+      return (T)ParseMethod.Invoke(null, new[] { x.Data });      
     }
   }  
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/String2XmlFormatter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/String2XmlFormatter.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/String2XmlFormatter.cs	(revision 1564)
@@ -8,19 +8,19 @@
 
   [EmptyStorableClass]
-  public class String2XmlFormatter : IFormatter {
-
-    public Type Type { get { return typeof(string); } }
-    public IFormat Format { get { return XmlFormat.Instance;  } }
-
-    public object DoFormat(object o) {      
-      return "<![CDATA[" +
-        ((string)o).Replace("]]>", "]]]]><![CDATA[>") +
-        "]]>";
+  public class String2XmlFormatter : FormatterBase<string, XmlString> {
+    
+    public override XmlString Format(string s) {
+      StringBuilder sb = new StringBuilder();
+      sb.Append("<![CDATA[");
+      sb.Append(s.Replace("]]>", "]]]]><![CDATA[>"));
+      sb.Append("]]>");
+      return new XmlString(sb.ToString());  
     }
 
-    public object Parse(object o) {
+    private static readonly string[] separators = new string[] { "<![CDATA[", "]]>" };
+
+    public override string Parse(XmlString x) {
       StringBuilder sb = new StringBuilder();
-      foreach (string s in ((string)o).Split(
-        new[] { "<![CDATA[", "]]>" },
+      foreach (string s in x.Data.Split(separators,        
         StringSplitOptions.RemoveEmptyEntries)) {
         sb.Append(s);
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlFormat.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlFormat.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlFormat.cs	(revision 1564)
@@ -5,8 +5,6 @@
 
   [EmptyStorableClass]
-  public class XmlFormat : FormatBase {
-    public override string Name { get { return "XML"; } }
-    public static readonly XmlFormat Instance = new XmlFormat();
-    private XmlFormat() { }
+  public class XmlFormat : FormatBase<XmlString> {
+    public override string Name { get { return "XML"; } }    
   }
 
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs	(revision 1564)
@@ -21,34 +21,6 @@
     public const string METAINFO = "METAINFO";
   }
-
-  public abstract class Generator<T> {
-    public T Format(ISerializationToken token) {
-      Type type = token.GetType();
-      if (type == typeof(BeginToken))
-        return Format((BeginToken)token);
-      if (type == typeof(EndToken))
-        return Format((EndToken)token);
-      if (type == typeof(PrimitiveToken))
-        return Format((PrimitiveToken)token);
-      if (type == typeof(ReferenceToken))
-        return Format((ReferenceToken)token);
-      if (type == typeof(NullReferenceToken))
-        return Format((NullReferenceToken)token);
-      if (type == typeof(MetaInfoBeginToken))
-        return Format((MetaInfoBeginToken)token);
-      if (type == typeof(MetaInfoEndToken))
-        return Format((MetaInfoEndToken)token);
-      throw new ApplicationException("Invalid token of type " + type.FullName);
-    }
-    protected abstract T Format(BeginToken beginToken);
-    protected abstract T Format(EndToken endToken);
-    protected abstract T Format(PrimitiveToken primitiveToken);
-    protected abstract T Format(ReferenceToken referenceToken);
-    protected abstract T Format(NullReferenceToken nullReferenceToken);
-    protected abstract T Format(MetaInfoBeginToken metaInfoBeginToken);
-    protected abstract T Format(MetaInfoEndToken metaInfoEndToken);
-  }
-
-  public class XmlGenerator : Generator<string> {
+  
+  public class XmlGenerator : GeneratorBase<string> {
     
     private int depth;
@@ -117,5 +89,5 @@
       return Prefix +
         FormatNode(XmlStrings.PRIMITIVE, attributes, NodeType.Start) +
-        dataToken.SerialData + "</" + XmlStrings.PRIMITIVE + ">\r\n";      
+        ((XmlString)dataToken.SerialData).Data + "</" + XmlStrings.PRIMITIVE + ">\r\n";      
     }
 
@@ -134,5 +106,5 @@
 
     protected override string Format(MetaInfoBeginToken metaInfoBeginToken) {
-      string result = Prefix + "<" + XmlStrings.METAINFO + ">";
+      string result = Prefix + "<" + XmlStrings.METAINFO + ">\r\n";
       depth += 1;
       return result;
@@ -141,5 +113,5 @@
     protected override string Format(MetaInfoEndToken metaInfoEndToken) {
       depth -= 1;
-      return Prefix + "</" + XmlStrings.METAINFO + ">";
+      return Prefix + "</" + XmlStrings.METAINFO + ">\r\n";
     }
 
@@ -156,5 +128,5 @@
 
     public static void Serialize(object o, string filename) {      
-      Serialize(o, filename, ConfigurationService.Instance.GetDefaultConfig(XmlFormat.Instance));
+      Serialize(o, filename, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));
     }
 
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs	(revision 1564)
@@ -62,5 +62,5 @@
         int.Parse(reader.GetAttribute("typeId")),
         id,
-        reader.ReadString());        
+        new XmlString(reader.ReadString()));
     }
 
@@ -69,8 +69,7 @@
       string idString = reader.GetAttribute("id");
       int? id = null;
-      int? typeId = null;
       if (idString != null)
         id = int.Parse(idString);
-        typeId = int.Parse(reader.GetAttribute("typeId"));
+      int typeId = int.Parse(reader.GetAttribute("typeId"));
       yield return new BeginToken(name, typeId, id);
       IEnumerator<ISerializationToken> iterator = GetEnumerator();
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlString.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlString.cs	(revision 1564)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlString.cs	(revision 1564)
@@ -0,0 +1,15 @@
+﻿using HeuristicLab.Persistence.Interfaces;
+using HeuristicLab.Persistence.Core;
+
+namespace HeuristicLab.Persistence.Default.Xml {
+  
+  public class XmlString : ISerialData {
+
+    [Storable]
+    public string Data { get; private set; }
+
+    public XmlString(string data) {
+      Data = data;
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj	(revision 1564)
@@ -95,7 +95,10 @@
     <Compile Include="Core\Configuration.cs" />
     <Compile Include="Core\EmptyStorableClassAttribute.cs" />
+    <Compile Include="Core\FormatBase.cs" />
+    <Compile Include="Core\FormatterBase.cs" />
     <Compile Include="Core\TypeExtensions.cs" />
     <Compile Include="Core\TypeMapping.cs" />
     <Compile Include="Core\TypeStringBuilder.cs" />
+    <Compile Include="Core\GeneratorBase.cs" />
     <Compile Include="Default\Decomposers\ArrayDecomposer.cs" />
     <Compile Include="Default\Decomposers\EnumerableDecomposer.cs" />
@@ -106,5 +109,7 @@
     <Compile Include="Default\Decomposers\TypeDecomposer.cs" />
     <Compile Include="Default\Decomposers\X2StringDecomposer.cs" />
-    <Compile Include="Default\ViewOnly\ViewOnlyFormat.cs" />
+    <Compile Include="Default\ViewOnly\ViewOnlyFormat.cs">
+      <SubType>Code</SubType>
+    </Compile>
     <Compile Include="Default\Xml\Compact\IntArray2XmlFormatters.cs" />
     <Compile Include="Default\Xml\Compact\DoubleArray2XmlFormatters.cs" />
@@ -114,4 +119,5 @@
     <Compile Include="Core\DataMemberAccessor.cs" />
     <Compile Include="Default\Xml\Compact\IntList2XmlFormatter.cs" />
+    <Compile Include="Default\Xml\XmlString.cs" />
     <Compile Include="Default\Xml\Primitive\Double2XmlFormatter.cs" />
     <Compile Include="Default\Xml\Primitive\Decimal2XmlFormatter.cs" />
@@ -134,6 +140,6 @@
     <Compile Include="Core\Deserializer.cs" />
     <Compile Include="Core\Tag.cs" />
+    <Compile Include="Interfaces\ISerialData.cs" />
     <Compile Include="Interfaces\IFormat.cs" />
-    <Compile Include="Core\FormatBase.cs" />
     <Compile Include="Interfaces\IDecomposer.cs" />
     <Compile Include="Interfaces\IFormatter.cs" />
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/IFormat.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/IFormat.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/IFormat.cs	(revision 1564)
@@ -3,6 +3,18 @@
 namespace HeuristicLab.Persistence.Interfaces {
 
+  /// <summary>
+  /// Interface of a new serialization output format. Instead of implementing this
+  /// interface, derive from FormatBase.
+  /// </summary>
   public interface IFormat {
     string Name { get; }
+    Type SerialDataType { get; }
+  }
+
+  /// <summary>
+  /// Marker interface for new serialization output format.  Instead of implementing this
+  /// interface, derive from FormatBase.
+  /// </summary>  
+  public interface IFormat<SerialDataFormat> : IFormat where SerialDataFormat : ISerialData {
   }
 
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/IFormatter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/IFormatter.cs	(revision 1563)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/IFormatter.cs	(revision 1564)
@@ -3,10 +3,25 @@
 namespace HeuristicLab.Persistence.Interfaces {
 
+  /// <summary>
+  /// Marker interface of serial data formatters. Transform data of type SourceType
+  /// into the serialization format SerialDataType. Derive from FormatterBase instead
+  /// of implementing this interface.
+  /// </summary>
   public interface IFormatter {
-    Type Type { get; }
-    IFormat Format { get; }
-    object DoFormat(object o);
-    object Parse(object o);
+    Type SerialDataType { get; }
+    Type SourceType { get; }
+    ISerialData Format(object o);
+    object Parse(ISerialData o);  
   }
 
+  /// <summary>
+  /// Marker interface of serial data formatters. Transform data of type Source
+  /// into the serialization format SerialData. Derive from FormatterBase instead
+  /// of implementing this interface.
+  /// </summary>  
+  public interface IFormatter<Source, SerialData> : IFormatter where SerialData : ISerialData {
+    SerialData Format(Source o);
+    Source Parse(SerialData t);
+  }  
+     
 }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/ISerialData.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/ISerialData.cs	(revision 1564)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/ISerialData.cs	(revision 1564)
@@ -0,0 +1,12 @@
+﻿using System;
+
+namespace HeuristicLab.Persistence.Interfaces {
+
+  
+  /// <summary>
+  /// Marker interface for serialized values generated and parsed by 
+  /// the formatter and output and read by generator and parser.
+  /// </summary>
+  public interface ISerialData { }
+
+}
