Changeset 1566


Ignore:
Timestamp:
04/16/09 12:58:14 (12 years ago)
Author:
epitzer
Message:

Format white space. (Ctrl-K, Ctrl-D) (#548)

Location:
trunk/sources
Files:
62 edited

Legend:

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

    r1565 r1566  
    1717    private readonly Dictionary<string, IFormatter> formatterTable;
    1818    private readonly Dictionary<string, bool> simpleFormatterTable;
    19     private readonly Dictionary<IFormatter, string> reverseFormatterTable;   
     19    private readonly Dictionary<IFormatter, string> reverseFormatterTable;
    2020    private readonly Dictionary<string, Type> typeNameTable;
    2121    private readonly Dictionary<Type, string> reverseTypeNameTable;
    2222
    23     public PersistenceConfigurationForm() {     
     23    public PersistenceConfigurationForm() {
    2424      InitializeComponent();
    2525      formatterTable = new Dictionary<string, IFormatter>();
     
    5252    }
    5353
    54     private void UpdateDecomposerList(ListView decomposerList, Configuration config) {     
     54    private void UpdateDecomposerList(ListView decomposerList, Configuration config) {
    5555      decomposerList.Items.Clear();
    5656      var availableDecomposers = new Dictionary<string, IDecomposer>();
    57       foreach (IDecomposer d in ConfigurationService.Instance.Decomposers) {       
     57      foreach (IDecomposer d in ConfigurationService.Instance.Decomposers) {
    5858        availableDecomposers.Add(d.GetType().VersionInvariantName(), d);
    59       }     
    60       foreach (IDecomposer decomposer in config.Decomposers) {       
    61         var item = decomposerList.Items.Add(decomposer.GetType().Name);       
     59      }
     60      foreach (IDecomposer decomposer in config.Decomposers) {
     61        var item = decomposerList.Items.Add(decomposer.GetType().Name);
    6262        item.Checked = true;
    6363        item.Tag = decomposer;
    6464        availableDecomposers.Remove(decomposer.GetType().VersionInvariantName());
    65       }     
     65      }
    6666      foreach (KeyValuePair<string, IDecomposer> pair in availableDecomposers) {
    6767        var item = decomposerList.Items.Add(pair.Value.GetType().Name);
     
    6969        item.Tag = pair.Value;
    7070      }
    71     }   
     71    }
    7272
    7373    private void UpdateFromConfigurationService() {
    74       foreach ( IFormat format in ConfigurationService.Instance.Formats ) {
     74      foreach (IFormat format in ConfigurationService.Instance.Formats) {
    7575        Configuration config = ConfigurationService.Instance.GetConfiguration(format);
    7676        UpdateFormatterGrid(
    7777          (DataGridView)GetControlsOnPage(format.Name, "GridView"),
    78           config);       
     78          config);
    7979        UpdateDecomposerList(
    8080          (ListView)GetControlsOnPage(format.Name, "DecomposerList"),
    8181          config);
    8282      }
    83     }   
     83    }
    8484
    8585    private void initializeConfigPages() {
    86       configurationTabs.TabPages.Clear();     
    87       foreach ( IFormat format in ConfigurationService.Instance.Formats ) {
     86      configurationTabs.TabPages.Clear();
     87      foreach (IFormat format in ConfigurationService.Instance.Formats) {
    8888        List<IFormatter> formatters = ConfigurationService.Instance.Formatters[format.SerialDataType];
    8989        TabPage page = new TabPage(format.Name) {
     
    107107        horizontalSplit.Panel1.Controls.Add(decomposerList);
    108108        DataGridView gridView = createGridView();
    109         verticalSplit.Panel2.Controls.Add(gridView);       
     109        verticalSplit.Panel2.Controls.Add(gridView);
    110110        fillDataGrid(gridView, formatters);
    111111        ListBox checkBox = new ListBox {
     
    167167        new ColumnHeader {
    168168          Name = "DecomposerColumn", Text = "Decomposers",
    169         });     
     169        });
    170170      foreach (IDecomposer decomposer in ConfigurationService.Instance.Decomposers) {
    171171        var item = decomposerList.Items.Add(decomposer.GetType().Name);
     
    176176    }
    177177
    178     private void fillDataGrid(DataGridView gridView, IEnumerable<IFormatter> formatters) {           
     178    private void fillDataGrid(DataGridView gridView, IEnumerable<IFormatter> formatters) {
    179179      Dictionary<string, List<string>> formatterMap = createFormatterMap(formatters);
    180       foreach ( var formatterMapping in formatterMap ) {
     180      foreach (var formatterMapping in formatterMap) {
    181181        var row = gridView.Rows[gridView.Rows.Add()];
    182182        row.Cells["Type"].Value = formatterMapping.Key;
    183183        row.Cells["Type"].ToolTipText = formatterMapping.Key;
    184         row.Cells["Active"].Value = true;       
    185         var comboBoxCell = (DataGridViewComboBoxCell) row.Cells["Formatter"];         
    186         foreach ( var formatter in formatterMapping.Value ) {
     184        row.Cells["Active"].Value = true;
     185        var comboBoxCell = (DataGridViewComboBoxCell)row.Cells["Formatter"];
     186        foreach (var formatter in formatterMapping.Value) {
    187187          comboBoxCell.Items.Add(formatter);
    188         }         
    189         comboBoxCell.Value = comboBoxCell.Items[0];         
     188        }
     189        comboBoxCell.Value = comboBoxCell.Items[0];
    190190        comboBoxCell.ToolTipText = comboBoxCell.Items[0].ToString();
    191191        if (comboBoxCell.Items.Count == 1) {
    192192          comboBoxCell.ReadOnly = true;
    193193          comboBoxCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
    194         }     
     194        }
    195195      }
    196196    }
    197197
    198198    private Dictionary<string, List<string>> createFormatterMap(IEnumerable<IFormatter> formatters) {
    199       var formatterMap = new Dictionary<string, List<string>>();     
     199      var formatterMap = new Dictionary<string, List<string>>();
    200200      foreach (var formatter in formatters) {
    201201        string formatterName = reverseFormatterTable[formatter];
    202         string typeName = reverseTypeNameTable[formatter.SourceType];         
     202        string typeName = reverseTypeNameTable[formatter.SourceType];
    203203        if (!formatterMap.ContainsKey(typeName))
    204204          formatterMap.Add(typeName, new List<string>());
     
    221221          }
    222222          simpleFormatterTable[formatter.GetType().Name] = true;
    223           formatterTable.Add(formatterName, formatter);         
     223          formatterTable.Add(formatterName, formatter);
    224224          reverseFormatterTable.Add(formatter, formatterName);
    225225
     
    244244        }
    245245      }
    246     }   
     246    }
    247247
    248248    void gridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) {
    249249      UpdatePreview();
    250     }   
     250    }
    251251
    252252    private void decomposerList_ItemDrag(object sender, ItemDragEventArgs e) {
    253       ListView decomposerList = (ListView) sender;
     253      ListView decomposerList = (ListView)sender;
    254254      decomposerList.DoDragDrop(decomposerList.SelectedItems, DragDropEffects.Move);
    255255    }
    256256
    257     private void decomposerList_DragEnter(object sender, DragEventArgs e) {     
    258       if ( e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection).FullName)) {
     257    private void decomposerList_DragEnter(object sender, DragEventArgs e) {
     258      if (e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection).FullName)) {
    259259        e.Effect = DragDropEffects.Move;
    260       } 
     260      }
    261261    }
    262262
     
    266266        return;
    267267      }
    268       Point cp = decomposerList.PointToClient(new Point(e.X, e.Y));     
    269       ListViewItem targetItem = decomposerList.GetItemAt(cp.X, cp.Y);     
     268      Point cp = decomposerList.PointToClient(new Point(e.X, e.Y));
     269      ListViewItem targetItem = decomposerList.GetItemAt(cp.X, cp.Y);
    270270      if (targetItem == null)
    271         return;           
    272       int targetIndex = targetItem.Index;     
     271        return;
     272      int targetIndex = targetItem.Index;
    273273      var selectedItems = new List<ListViewItem>(decomposerList.SelectedItems.Cast<ListViewItem>());
    274274      int i = 0;
    275       foreach ( ListViewItem dragItem in selectedItems ) {               
     275      foreach (ListViewItem dragItem in selectedItems) {
    276276        if (targetIndex == dragItem.Index)
    277277          return;
    278278        if (dragItem.Index < targetIndex) {
    279           decomposerList.Items.Insert(targetIndex + 1, (ListViewItem) dragItem.Clone());
     279          decomposerList.Items.Insert(targetIndex + 1, (ListViewItem)dragItem.Clone());
    280280        } else {
    281           decomposerList.Items.Insert(targetIndex + i, (ListViewItem)dragItem.Clone());         
    282         }       
     281          decomposerList.Items.Insert(targetIndex + i, (ListViewItem)dragItem.Clone());
     282        }
    283283        decomposerList.Items.Remove(dragItem);
    284284        i++;
     
    288288
    289289    private void decomposerList_Resize(object sender, EventArgs e) {
    290       ListView decomposerList = (ListView)sender;     
    291       decomposerList.Columns["DecomposerColumn"].Width = decomposerList.Width - 4;     
    292     }
    293    
     290      ListView decomposerList = (ListView)sender;
     291      decomposerList.Columns["DecomposerColumn"].Width = decomposerList.Width - 4;
     292    }
     293
    294294    private void UpdatePreview() {
    295       ListBox checkBox = (ListBox)GetActiveControl("CheckBox");     
     295      ListBox checkBox = (ListBox)GetActiveControl("CheckBox");
    296296      IFormat activeFormat = (IFormat)configurationTabs.SelectedTab.Tag;
    297       if (activeFormat != null && checkBox != null ) {
     297      if (activeFormat != null && checkBox != null) {
    298298        checkBox.Items.Clear();
    299299        Configuration activeConfig = GetActiveConfiguration();
     
    302302        }
    303303        foreach (var decomposer in activeConfig.Decomposers)
    304           checkBox.Items.Add(decomposer.GetType().Name + " (D)");     
    305       }     
     304          checkBox.Items.Add(decomposer.GetType().Name + " (D)");
     305      }
    306306    }
    307307
     
    316316      } else {
    317317        return null;
    318       }     
    319     }
    320 
    321     private Control GetControlsOnPage(string pageName, string name) {     
     318      }
     319    }
     320
     321    private Control GetControlsOnPage(string pageName, string name) {
    322322      Control[] controls = configurationTabs.TabPages[pageName].Controls.Find(name, true);
    323323      if (controls.Length == 1) {
     
    325325      } else {
    326326        return null;
    327       }     
     327      }
    328328    }
    329329
     
    358358
    359359    private Configuration GetConfiguration(IFormat format) {
    360        return GenerateConfiguration(format,
    361         (DataGridView)GetControlsOnPage(format.Name, "GridView"),
    362         (ListView)GetControlsOnPage(format.Name, "DecomposerList"));
    363     }
    364    
     360      return GenerateConfiguration(format,
     361       (DataGridView)GetControlsOnPage(format.Name, "GridView"),
     362       (ListView)GetControlsOnPage(format.Name, "DecomposerList"));
     363    }
     364
    365365    private void updateButton_Click(object sender, EventArgs e) {
    366366      IFormat format = (IFormat)configurationTabs.SelectedTab.Tag;
     
    368368        ConfigurationService.Instance.DefineConfiguration(
    369369          GetActiveConfiguration());
    370     }   
    371    
     370    }
     371
    372372  }
    373373
     
    383383
    384384    public override Empty Format(Type o) {
    385      return null;
     385      return null;
    386386    }
    387387
     
    400400    public override bool Parse(Empty o) {
    401401      return false;
    402     }   
    403   } 
     402    }
     403  }
    404404
    405405  [EmptyStorableClass]
     
    424424    }
    425425
    426     private static void SimpleFullName(Type type, StringBuilder sb) {     
     426    private static void SimpleFullName(Type type, StringBuilder sb) {
    427427      if (type.IsGenericType) {
    428428        sb.Append(type.Name, 0, type.Name.LastIndexOf('`'));
  • trunk/sources/HeuristicLab.Persistence.Test/NewSerializationTest.cs

    r1565 r1566  
    2424    [Storable] private ulong _ulong = 123456;
    2525    [Storable] private long[,] _long_array =
    26       new long[,] { { 123, 456, },  {789, 123 }} ;
     26      new long[,] { { 123, 456, }, { 789, 123 } };
    2727    [Storable] public List<int> list = new List<int>{ 1, 2, 3, 4, 5};
    2828  }
     
    176176  public class NewSerializationTest {
    177177
    178     public static void Test1() {     
     178    public static void Test1() {
    179179      Root r = new Root();
    180       r.selfReferences = new List<Root> {r, r};
    181       r.c = new Custom {r = r};
     180      r.selfReferences = new List<Root> { r, r };
     181      r.c = new Custom { r = r };
    182182      r.dict.Add("one", 1);
    183183      r.dict.Add("two", 2);
    184184      r.dict.Add("three", 3);
    185185      r.myEnum = TestEnum.va1;
    186       XmlGenerator.Serialize(r, "test.zip");     
    187       object o = XmlParser.DeSerialize("test.zip");     
     186      XmlGenerator.Serialize(r, "test.zip");
     187      object o = XmlParser.DeSerialize("test.zip");
    188188      Console.WriteLine(ViewOnlyGenerator.Serialize(r));
    189189      Console.WriteLine(ViewOnlyGenerator.Serialize(o));
     
    198198      c.kvpList = new KeyValuePair<List<C>, C>(new List<C> { c }, c);
    199199      XmlGenerator.Serialize(cs, "test3.zip");
    200       object o = XmlParser.DeSerialize("test3.zip");     
     200      object o = XmlParser.DeSerialize("test3.zip");
    201201      Console.WriteLine(ViewOnlyGenerator.Serialize(cs));
    202202      Console.WriteLine(ViewOnlyGenerator.Serialize(o));
     
    218218      arrayListArray[2].Add(a);
    219219      XmlGenerator.Serialize(arrayListArray, "test4.zip");
    220       object o = XmlParser.DeSerialize("test4.zip");     
     220      object o = XmlParser.DeSerialize("test4.zip");
    221221      Console.WriteLine(ViewOnlyGenerator.Serialize(arrayListArray));
    222222      Console.WriteLine(ViewOnlyGenerator.Serialize(o));
     
    224224
    225225    public static void Test2() {
    226       Manager m = new Manager();     
     226      Manager m = new Manager();
    227227      XmlGenerator.Serialize(m, "test2.zip");
    228228      object o = XmlParser.DeSerialize("test2.zip");
    229229      Console.WriteLine(ViewOnlyGenerator.Serialize(m));
    230       Console.WriteLine(ViewOnlyGenerator.Serialize(o));     
    231     }   
    232 
    233    
     230      Console.WriteLine(ViewOnlyGenerator.Serialize(o));
     231    }
     232
     233
    234234
    235235    public static void Test5() {
    236       StringDecomposerTest sdt = new StringDecomposerTest();     
     236      StringDecomposerTest sdt = new StringDecomposerTest();
    237237      XmlGenerator.Serialize(sdt, "test5.zip");
    238238      object o = XmlParser.DeSerialize("test5.zip");
     
    267267
    268268    public static void Test8() {
    269       string[] strings = { "ora", "et", "labora" };     
     269      string[] strings = { "ora", "et", "labora" };
    270270      XmlGenerator.Serialize(strings, "test8.zip");
    271271      object o = XmlParser.DeSerialize("test8.zip");
     
    278278      //BinaryGenerator.Serialize(r, "test.bin");
    279279    }
    280    
     280
    281281    class Float {
    282282      [Storable]
     
    284284    }
    285285
    286     public static void Test10() {           
     286    public static void Test10() {
    287287      XmlGenerator.Serialize(12.3f, "test9.zip");
    288288      object o = XmlParser.DeSerialize("test9.zip");
     
    295295      BasicConfigurator.Configure();
    296296      ConfigurationService.Instance.Reset();
    297       Test1();     
     297      Test1();
    298298      Test2();
    299299      Test3();
  • trunk/sources/HeuristicLab.Persistence.Test/SerializationTest.cs

    r1454 r1566  
    3636
    3737  }
    38    
     38
    3939  class SerializationTest {
    4040    public static void Main() {
  • trunk/sources/HeuristicLab.Persistence.Test/StorableAttributeTests.cs

    r1555 r1566  
    77  class TestClass {
    88
    9     [Storable(Name="TestProperty", DefaultValue=12)]
     9    [Storable(Name = "TestProperty", DefaultValue = 12)]
    1010    public object o;
    1111
     
    2222      TestClass t = new TestClass();
    2323      Dictionary<string, DataMemberAccessor> accessors = StorableAttribute.GetStorableAccessors(t);
    24       foreach ( KeyValuePair<string, DataMemberAccessor> pair in accessors ) {
     24      foreach (KeyValuePair<string, DataMemberAccessor> pair in accessors) {
    2525        Console.WriteLine(pair.Key + ": " + pair.Value);
    2626      }
     
    3333        accessors["y"].Set(0);
    3434        throw new InvalidOperationException();
    35       } catch ( KeyNotFoundException ) { }
     35      } catch (KeyNotFoundException) { }
    3636      Console.ReadLine();
    3737    }
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Configuration.cs

    r1564 r1566  
    1414    private readonly Dictionary<Type, IDecomposer> decomposerCache;
    1515
    16     [Storable]   
     16    [Storable]
    1717    public IFormat Format { get; private set; }
    1818
     
    2424      this.Format = format;
    2525      this.formatters = new Dictionary<Type, IFormatter>();
    26       foreach ( var pair in formatters ) {
    27         if (pair.Value.SerialDataType != format.SerialDataType ) {
     26      foreach (var pair in formatters) {
     27        if (pair.Value.SerialDataType != format.SerialDataType) {
    2828          throw new ArgumentException("All formatters must have the same IFormat.");
    2929        }
     
    3131      }
    3232      this.decomposers = new List<IDecomposer>(decomposers);
    33       decomposerCache = new Dictionary<Type, IDecomposer>();     
     33      decomposerCache = new Dictionary<Type, IDecomposer>();
    3434    }
    3535
     
    4242    }
    4343
    44     public IFormatter GetFormatter(Type type) {     
     44    public IFormatter GetFormatter(Type type) {
    4545      IFormatter formatter;
    4646      formatters.TryGetValue(type, out formatter);
     
    5050    public IDecomposer GetDecomposer(Type type) {
    5151      if (decomposerCache.ContainsKey(type))
    52         return decomposerCache[type];     
     52        return decomposerCache[type];
    5353      foreach (IDecomposer d in decomposers) {
    5454        if (d.CanDecompose(type)) {
     
    5959      decomposerCache.Add(type, null);
    6060      return null;
    61     }   
    62   } 
    63  
     61    }
     62  }
     63
    6464}
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs

    r1564 r1566  
    1010
    1111namespace HeuristicLab.Persistence.Core {
    12  
     12
    1313  public class ConfigurationService {
    1414
     
    1818    public List<IDecomposer> Decomposers { get; private set; }
    1919    public List<IFormat> Formats { get; private set; }
    20    
     20
    2121    public static ConfigurationService Instance {
    2222      get {
     
    5454        }
    5555      } catch (Exception e) {
    56         Logger.Warn("Could not load settings.", e);       
     56        Logger.Warn("Could not load settings.", e);
    5757      }
    5858    }
    5959
    60     public void SaveSettings() {     
     60    public void SaveSettings() {
    6161      Serializer serializer = new Serializer(
    6262        customConfigurations,
     
    7878    }
    7979
    80     public void Reset() {     
     80    public void Reset() {
    8181      customConfigurations.Clear();
    8282      Formatters.Clear();
     
    8585      DiscoverFrom(defaultAssembly);
    8686      foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
    87         if ( a != defaultAssembly )
     87        if (a != defaultAssembly)
    8888          DiscoverFrom(a);
    8989      SortDecomposers();
     
    102102    protected void DiscoverFrom(Assembly a) {
    103103      foreach (Type t in a.GetTypes()) {
    104         if (t.GetInterface(typeof (IFormatter).FullName) != null) {
     104        if (t.GetInterface(typeof(IFormatter).FullName) != null) {
    105105          try {
    106             IFormatter formatter = (IFormatter) Activator.CreateInstance(t, true);
    107             if ( ! Formatters.ContainsKey(formatter.SerialDataType) ) {
     106            IFormatter formatter = (IFormatter)Activator.CreateInstance(t, true);
     107            if (!Formatters.ContainsKey(formatter.SerialDataType)) {
    108108              Formatters.Add(formatter.SerialDataType, new List<IFormatter>());
    109109            }
     
    114114              formatter.SerialDataType.VersionInvariantName()));
    115115          } catch (MissingMethodException e) {
    116             Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);           
     116            Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);
    117117          } catch (ArgumentException e) {
    118118            Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);
    119119          }
    120120        }
    121         if (t.GetInterface(typeof (IDecomposer).FullName) != null) {
     121        if (t.GetInterface(typeof(IDecomposer).FullName) != null) {
    122122          try {
    123             Decomposers.Add((IDecomposer) Activator.CreateInstance(t, true));
     123            Decomposers.Add((IDecomposer)Activator.CreateInstance(t, true));
    124124            Logger.Debug("discovered decomposer " + t.VersionInvariantName());
    125125          } catch (MissingMethodException e) {
    126             Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);         
     126            Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);
    127127          } catch (ArgumentException e) {
    128128            Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);
     
    136136              format.Name,
    137137              format.SerialDataType,
    138               t.VersionInvariantName()));             
     138              t.VersionInvariantName()));
    139139          } catch (MissingMethodException e) {
    140             Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);         
     140            Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);
    141141          } catch (ArgumentException e) {
    142142            Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);
    143           }         
     143          }
    144144        }
    145145      }
     
    148148    public Configuration GetDefaultConfig(IFormat format) {
    149149      Dictionary<Type, IFormatter> formatterConfig = new Dictionary<Type, IFormatter>();
    150       foreach ( IFormatter f in Formatters[format.SerialDataType] ) {
    151         if ( ! formatterConfig.ContainsKey(f.SourceType) )
     150      foreach (IFormatter f in Formatters[format.SerialDataType]) {
     151        if (!formatterConfig.ContainsKey(f.SourceType))
    152152          formatterConfig.Add(f.SourceType, f);
    153153      }
     
    161161    }
    162162
    163     public void DefineConfiguration(Configuration configuration) {     
     163    public void DefineConfiguration(Configuration configuration) {
    164164      customConfigurations[configuration.Format] = configuration;
    165165      SaveSettings();
     
    167167
    168168  }
    169  
     169
    170170}
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/DataMemberAccessor.cs

    r1542 r1566  
    1111    public readonly Getter Get;
    1212    public readonly Setter Set;
    13     public readonly string Name;   
     13    public readonly string Name;
    1414    public readonly object DefaultValue;
    1515
     
    2121        FieldInfo fieldInfo = (FieldInfo)memberInfo;
    2222        Get = () => fieldInfo.GetValue(obj);
    23         Set = value => fieldInfo.SetValue(obj, value);       
     23        Set = value => fieldInfo.SetValue(obj, value);
    2424      } else if (memberInfo.MemberType == MemberTypes.Property) {
    2525        PropertyInfo propertyInfo = (PropertyInfo)memberInfo;
     
    2929        }
    3030        Get = () => propertyInfo.GetValue(obj, null);
    31         Set = value => propertyInfo.SetValue(obj, value, null);       
     31        Set = value => propertyInfo.SetValue(obj, value, null);
    3232      } else {
    3333        throw new NotSupportedException(
     
    4141        string name, object defaultValue,
    4242        Getter getter, Setter setter) {
    43       Name = name;     
     43      Name = name;
    4444      DefaultValue = defaultValue;
    4545      Get = getter;
     
    4848
    4949    public DataMemberAccessor(object o) {
    50       Name = null;     
     50      Name = null;
    5151      DefaultValue = null;
    5252      Get = () => o;
     
    5555
    5656    public DataMemberAccessor(object o, string name) {
    57       Name = name;     
     57      Name = name;
    5858      DefaultValue = null;
    5959      Get = () => o;
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/DeSerializer.cs

    r1556 r1566  
    44using HeuristicLab.Persistence.Core.Tokens;
    55
    6 namespace HeuristicLab.Persistence.Core { 
     6namespace HeuristicLab.Persistence.Core {
    77
    8   public class ParentReference {
     8  public class ParentReference { }
    99
    1010  class Midwife {
    11    
    12     public int? Id { get; private set; }   
     11
     12    public int? Id { get; private set; }
    1313    public bool MetaMode { get; set; }
    1414    public object Obj { get; private set; }
     
    2222      this.Obj = value;
    2323    }
    24        
    25     public Midwife(Type type, IDecomposer decomposer, int? id) {   
     24
     25    public Midwife(Type type, IDecomposer decomposer, int? id) {
    2626      this.type = type;
    27       this.decomposer = decomposer;     
     27      this.decomposer = decomposer;
    2828      this.Id = id;
    29       MetaMode = false;     
     29      MetaMode = false;
    3030      metaInfo = new List<Tag>();
    31       customValues = new List<Tag>();           
     31      customValues = new List<Tag>();
    3232    }
    3333
     
    3535      if (Obj != null)
    3636        throw new ApplicationException("object already instantiated");
    37       Obj = decomposer.CreateInstance(type, metaInfo);     
     37      Obj = decomposer.CreateInstance(type, metaInfo);
    3838    }
    3939
     
    4949      decomposer.Populate(Obj, customValues, type);
    5050    }
    51   } 
     51  }
    5252
    5353  public class Deserializer {
    54    
     54
    5555    private readonly Dictionary<int, object> id2obj;
    5656    private readonly Dictionary<Type, object> serializerMapping;
    57     private readonly Stack<Midwife> parentStack;   
     57    private readonly Stack<Midwife> parentStack;
    5858    private readonly Dictionary<int, Type> typeIds;
    5959
     
    7979    }
    8080
    81     public object Deserialize(IEnumerable<ISerializationToken> tokens) {     
     81    public object Deserialize(IEnumerable<ISerializationToken> tokens) {
    8282      foreach (ISerializationToken token in tokens) {
    8383        Type t = token.GetType();
    84         if ( t == typeof(BeginToken) ) {
     84        if (t == typeof(BeginToken)) {
    8585          CompositeStartHandler((BeginToken)token);
    86         } else if ( t == typeof(EndToken) ) {
    87           CompositeEndHandler((EndToken) token);
    88         } else if ( t == typeof(PrimitiveToken) ) {
    89           PrimitiveHandler((PrimitiveToken) token);
    90         } else if ( t == typeof(ReferenceToken) ) {
    91           ReferenceHandler((ReferenceToken) token);
     86        } else if (t == typeof(EndToken)) {
     87          CompositeEndHandler((EndToken)token);
     88        } else if (t == typeof(PrimitiveToken)) {
     89          PrimitiveHandler((PrimitiveToken)token);
     90        } else if (t == typeof(ReferenceToken)) {
     91          ReferenceHandler((ReferenceToken)token);
    9292        } else if (t == typeof(NullReferenceToken)) {
    9393          NullHandler((NullReferenceToken)token);
     
    106106      Type type = typeIds[(int)token.TypeId];
    107107      IDecomposer decomposer = null;
    108       if ( serializerMapping.ContainsKey(type) )
     108      if (serializerMapping.ContainsKey(type))
    109109        decomposer = serializerMapping[type] as IDecomposer;
    110110      if (decomposer == null)
     
    124124    private void PrimitiveHandler(PrimitiveToken token) {
    125125      Type type = typeIds[(int)token.TypeId];
    126       object value = ((IFormatter) serializerMapping[type]).Parse(token.SerialData);
    127       if ( token.Id != null )     
     126      object value = ((IFormatter)serializerMapping[type]).Parse(token.SerialData);
     127      if (token.Id != null)
    128128        id2obj[(int)token.Id] = value;
    129129      SetValue(token.Name, value);
     
    144144
    145145    private void MetaInfoEnd(MetaInfoEndToken token) {
    146       Midwife m = parentStack.Peek();     
     146      Midwife m = parentStack.Peek();
    147147      m.MetaMode = false;
    148148      CreateInstance(m);
     
    152152      m.CreateInstance();
    153153      if (m.Id != null)
    154         id2obj.Add((int)m.Id, m.Obj);     
     154        id2obj.Add((int)m.Id, m.Obj);
    155155    }
    156156
    157157    private void SetValue(string name, object value) {
    158       if (parentStack.Count == 0) {       
     158      if (parentStack.Count == 0) {
    159159        parentStack.Push(new Midwife(value));
    160160      } else {
     
    162162        if (m.MetaMode == false && m.Obj == null)
    163163          CreateInstance(m);
    164         m.AddValue(name, value);       
     164        m.AddValue(name, value);
    165165      }
    166166    }
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/EmptyStorableClassAttribute.cs

    r1555 r1566  
    55namespace HeuristicLab.Persistence.Core {
    66
    7  
     7
    88  [AttributeUsage(
    99    AttributeTargets.Class,
    10     AllowMultiple=false,
    11     Inherited=false)]
     10    AllowMultiple = false,
     11    Inherited = false)]
    1212  public class EmptyStorableClassAttribute : Attribute {
    1313
    1414    private static readonly Dictionary<Type, bool> emptyTypeInfo = new Dictionary<Type, bool>();
    15     public static bool IsEmptyStorable(Type type) {     
     15    public static bool IsEmptyStorable(Type type) {
    1616      if (emptyTypeInfo.ContainsKey(type))
    1717        return emptyTypeInfo[type];
     
    2424      }
    2525      int nFields = 0;
    26       foreach ( MemberInfo memberInfo in type.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ) {
     26      foreach (MemberInfo memberInfo in type.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) {
    2727        if (memberInfo.MemberType == MemberTypes.Field ||
    2828          memberInfo.MemberType == MemberTypes.Property)
     
    3636      return false;
    3737    }
    38   } 
     38  }
    3939}
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/FormatBase.cs

    r1564 r1566  
    1616
    1717    public override bool Equals(object obj) {
    18       FormatBase<SerialDataFormat> f = obj as FormatBase<SerialDataFormat>;     
     18      FormatBase<SerialDataFormat> f = obj as FormatBase<SerialDataFormat>;
    1919      return Equals(f);
    2020    }
    21    
     21
    2222  }
    2323
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/FormatterBase.cs

    r1564 r1566  
    22
    33namespace HeuristicLab.Persistence.Interfaces {
    4  
     4
    55  public abstract class FormatterBase<Source, SerialData> : IFormatter<Source, SerialData> where SerialData : ISerialData {
    66
     
    1414
    1515    ISerialData IFormatter.Format(object o) {
    16       return Format((Source)o);   
     16      return Format((Source)o);
    1717    }
    1818
     
    2222
    2323  }
    24      
     24
    2525}
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/GeneratorBase.cs

    r1564 r1566  
    1111
    1212namespace HeuristicLab.Persistence.Core {
    13  
     13
    1414  public abstract class GeneratorBase<T> {
    1515    public T Format(ISerializationToken token) {
     
    3838    protected abstract T Format(MetaInfoBeginToken metaInfoBeginToken);
    3939    protected abstract T Format(MetaInfoEndToken metaInfoEndToken);
    40   } 
     40  }
    4141}
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Serializer.cs

    r1564 r1566  
    1616
    1717    public List<TypeMapping> TypeCache {
    18       get {       
     18      get {
    1919        List<TypeMapping> result = new List<TypeMapping>();
    2020        foreach (var pair in typeCache) {
     
    3030          result.Add(new TypeMapping(pair.Value, pair.Key.VersionInvariantName(), serializer));
    3131        }
    32         return result;                                     
     32        return result;
    3333      }
    3434    }
    3535
    36     public Serializer(object obj, Configuration configuration) :       
     36    public Serializer(object obj, Configuration configuration) :
    3737      this(obj, configuration, "ROOT") { }
    3838
     
    4040      this.obj = obj;
    4141      this.rootName = rootName;
    42       this.configuration = configuration;     
    43       obj2id = new Dictionary<object, int> {{new object(), 0}};
     42      this.configuration = configuration;
     43      obj2id = new Dictionary<object, int> { { new object(), 0 } };
    4444      typeCache = new Dictionary<Type, int>();
    4545    }
     
    5252      return Serialize(new DataMemberAccessor(rootName, null, () => obj, null));
    5353    }
    54    
     54
    5555    private IEnumerator<ISerializationToken> Serialize(DataMemberAccessor accessor) {
    5656      object value = accessor.Get();
     
    5858        return NullReferenceEnumerator(accessor.Name);
    5959      if (obj2id.ContainsKey(value))
    60         return ReferenceEnumerator(accessor.Name, obj2id[value]);             
    61       if ( ! typeCache.ContainsKey(value.GetType()))
     60        return ReferenceEnumerator(accessor.Name, obj2id[value]);
     61      if (!typeCache.ContainsKey(value.GetType()))
    6262        typeCache.Add(value.GetType(), typeCache.Count);
    6363      int typeId = typeCache[value.GetType()];
    6464      int? id = null;
    65       if ( ! value.GetType().IsValueType) {
     65      if (!value.GetType().IsValueType) {
    6666        id = obj2id.Count;
    6767        obj2id.Add(value, (int)id);
     
    7070      if (formatter != null)
    7171        return PrimitiveEnumerator(accessor.Name, typeId, formatter.Format(value), id);
    72       IDecomposer decomposer = configuration.GetDecomposer(value.GetType()); 
     72      IDecomposer decomposer = configuration.GetDecomposer(value.GetType());
    7373      if (decomposer != null)
    7474        return CompositeEnumerator(accessor.Name, decomposer.Decompose(value), id, typeId, decomposer.CreateMetaInfo(value));
     
    7676          String.Format(
    7777          "No suitable method for serializing values of type \"{0}\" found.",
    78           value.GetType().VersionInvariantName()));     
     78          value.GetType().VersionInvariantName()));
    7979    }
    8080
     
    9494    private IEnumerator<ISerializationToken> CompositeEnumerator(
    9595        string name, IEnumerable<Tag> tags, int? id, int typeId, IEnumerable<Tag> metaInfo) {
    96       yield return new BeginToken(name, typeId, id);     
     96      yield return new BeginToken(name, typeId, id);
    9797      bool first = true;
    9898      foreach (var tag in metaInfo) {
     
    114114          yield return it.Current;
    115115      }
    116       yield return new EndToken(name, typeId, id);       
     116      yield return new EndToken(name, typeId, id);
    117117    }
    118118
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/StorableAttribute.cs

    r1555 r1566  
    77  [AttributeUsage(
    88    AttributeTargets.Field | AttributeTargets.Property,
    9     AllowMultiple=false,
    10     Inherited=false)]
     9    AllowMultiple = false,
     10    Inherited = false)]
    1111  public class StorableAttribute : Attribute {
    1212
     
    1919      BindingFlags.NonPublic |
    2020      BindingFlags.DeclaredOnly;
    21    
     21
    2222    public static IEnumerable<KeyValuePair<StorableAttribute, MemberInfo>> GetStorableMembers(Type type) {
    23       return GetStorableMembers(type, true);     
     23      return GetStorableMembers(type, true);
    2424    }
    2525
     
    2727        GetStorableMembers(Type type, bool inherited) {
    2828      if (type.BaseType != null)
    29         foreach ( var pair in GetStorableMembers(type.BaseType) )
     29        foreach (var pair in GetStorableMembers(type.BaseType))
    3030          yield return pair;
    3131      foreach (MemberInfo memberInfo in type.GetMembers(instanceMembers)) {
    32         foreach (object attribute in memberInfo.GetCustomAttributes(false)) {         
     32        foreach (object attribute in memberInfo.GetCustomAttributes(false)) {
    3333          StorableAttribute storableAttribute =
    3434            attribute as StorableAttribute;
    3535          if (storableAttribute != null) {
    36             yield return new KeyValuePair<StorableAttribute, MemberInfo>(storableAttribute, memberInfo);           
     36            yield return new KeyValuePair<StorableAttribute, MemberInfo>(storableAttribute, memberInfo);
    3737          }
    3838        }
    39       }     
     39      }
    4040    }
    4141
     
    4646        storableAccessors.Add(pair.Value.Name,
    4747          new DataMemberAccessor(pair.Value, pair.Key, obj));
    48       }           
     48      }
    4949      return storableAccessors;
    50     }   
     50    }
    5151  }
    5252}
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Tag.cs

    r1553 r1566  
    55  public class Tag {
    66    public string Name { get; private set; }
    7     public object Value { get; set; }     
     7    public object Value { get; set; }
    88
    99    public Tag(string name, object value) {
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Tokens/MetaInfoEndToken.cs

    r1556 r1566  
    44
    55  public class MetaInfoEndToken : ISerializationToken { }
    6  
     6
    77}
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Tokens/NulLReferenceToken.cs

    r1556 r1566  
    22
    33namespace HeuristicLab.Persistence.Core.Tokens {
    4  
     4
    55  public class NullReferenceToken : SerializationTokenBase {
    66    public NullReferenceToken(string name) : base(name) { }
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Tokens/PrimitiveToken.cs

    r1564 r1566  
    22
    33namespace HeuristicLab.Persistence.Core.Tokens {
    4  
    5   public class PrimitiveToken : SerializationTokenBase {   
     4
     5  public class PrimitiveToken : SerializationTokenBase {
    66    public readonly int TypeId;
    77    public readonly int? Id;
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Tokens/ReferenceToken.cs

    r1556 r1566  
    22
    33namespace HeuristicLab.Persistence.Core.Tokens {
    4  
    5   public class ReferenceToken : SerializationTokenBase {   
     4
     5  public class ReferenceToken : SerializationTokenBase {
    66    public readonly int Id;
    77    public ReferenceToken(string name, int id)
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/TypeExtensions.cs

    r1555 r1566  
    33
    44namespace HeuristicLab.Persistence.Core {
    5  
     5
    66  public static class TypeExtensions {
    77
     
    1212    }
    1313
    14   } 
    15  
     14  }
     15
    1616}
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/TypeMapping.cs

    r1542 r1566  
    66    public readonly int Id;
    77    public readonly string TypeName;
    8     public readonly string Serializer;   
     8    public readonly string Serializer;
    99    public TypeMapping(int id, string typeName, string serializer) {
    1010      Id = id;
     
    1616        {"id", Id},
    1717        {"typeName", TypeName},
    18         {"serializer", Serializer}};                                           
     18        {"serializer", Serializer}};
    1919    }
    20   } 
     20  }
    2121
    2222}
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/TypeStringBuilder.cs

    r1555 r1566  
    77
    88    internal static void BuildDeclaringTypeChain(Type type, StringBuilder sb) {
    9       if ( type.DeclaringType != null ) {
     9      if (type.DeclaringType != null) {
    1010        BuildDeclaringTypeChain(type.DeclaringType, sb);
    1111        sb.Append(type.DeclaringType.Name).Append('+');
     
    2020        sb.Append("[");
    2121        Type[] args = type.GetGenericArguments();
    22         for ( int i = 0; i<args.Length; i++ ) {
     22        for (int i = 0; i < args.Length; i++) {
    2323          sb.Append("[");
    2424          BuildVersionInvariantName(args[i], sb);
     
    2828          sb.Remove(sb.Length - 1, 1);
    2929        sb.Append("]");
    30       }           
     30      }
    3131      sb.Append(", ").Append(type.Assembly.GetName().Name);
    3232    }
    3333
    3434  }
    35  
     35
    3636}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/ArrayDecomposer.cs

    r1563 r1566  
    55
    66namespace HeuristicLab.Persistence.Default.Decomposers {
    7    
     7
    88  [EmptyStorableClass]
    99  public class ArrayDecomposer : IDecomposer {
     
    2020      Array a = (Array)obj;
    2121      yield return new Tag("rank", a.Rank);
    22       for (int i = 0; i < a.Rank; i++) {     
     22      for (int i = 0; i < a.Rank; i++) {
    2323        yield return new Tag("length_" + i, a.GetLength(i));
    2424      }
    25       for (int i = 0; i < a.Rank; i++) {       
     25      for (int i = 0; i < a.Rank; i++) {
    2626        yield return new Tag("lowerBound_" + i, a.GetLowerBound(i));
    27       }     
     27      }
    2828    }
    2929
    3030    public IEnumerable<Tag> Decompose(object array) {
    31       Array a = (Array)array;     
     31      Array a = (Array)array;
    3232      int[] lengths = new int[a.Rank];
    3333      int[] lowerBounds = new int[a.Rank];
     
    6767        lowerBounds[i] = (int)e.Current.Value;
    6868      }
    69       return Array.CreateInstance(t.GetElementType(), lengths, lowerBounds);     
     69      return Array.CreateInstance(t.GetElementType(), lengths, lowerBounds);
    7070    }
    7171
    72     public void Populate(object instance, IEnumerable<Tag> elements, Type t) {     
     72    public void Populate(object instance, IEnumerable<Tag> elements, Type t) {
    7373      Array a = (Array)instance;
    7474      int[] lengths = new int[a.Rank];
     
    7979      for (int i = 0; i < a.Rank; i++) {
    8080        lowerBounds[i] = a.GetLowerBound(i);
    81       }     
     81      }
    8282      int[] positions = (int[])lowerBounds.Clone();
    8383      IEnumerator<Tag> e = elements.GetEnumerator();
     
    8686        a.SetValue(e.Current.Value, currentPositions);
    8787        positions[0] += 1;
    88         for (int i = 0; i < a.Rank-1; i++) {
    89           if (positions[i] >= lengths[i]+lowerBounds[i]) {
     88        for (int i = 0; i < a.Rank - 1; i++) {
     89          if (positions[i] >= lengths[i] + lowerBounds[i]) {
    9090            positions[i] = lowerBounds[i];
    9191            positions[i + 1] += 1;
     
    9797    }
    9898  }
    99  
     99
    100100}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/DictionaryDecomposer.cs

    r1563 r1566  
    55using System.Collections.Generic;
    66
    7 namespace HeuristicLab.Persistence.Default.Decomposers { 
    8  
     7namespace HeuristicLab.Persistence.Default.Decomposers {
     8
    99  [EmptyStorableClass]
    1010  public class DictionaryDecomposer : IDecomposer {
     
    1616
    1717    public bool CanDecompose(Type type) {
    18       return type.GetInterface(typeof(IDictionary).FullName) != null;       
     18      return type.GetInterface(typeof(IDictionary).FullName) != null;
    1919    }
    2020
     
    2424
    2525    public IEnumerable<Tag> Decompose(object o) {
    26       IDictionary dict = (IDictionary)o;     
    27       foreach ( DictionaryEntry entry in dict) {
     26      IDictionary dict = (IDictionary)o;
     27      foreach (DictionaryEntry entry in dict) {
    2828        yield return new Tag("key", entry.Key);
    2929        yield return new Tag("value", entry.Value);
     
    4343        Tag value = iter.Current;
    4444        dict.Add(key.Value, value.Value);
    45       }     
     45      }
    4646    }
    4747  }
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/EnumDecomposer.cs

    r1563 r1566  
    55
    66namespace HeuristicLab.Persistence.Default.Decomposers {
    7    
     7
    88  [EmptyStorableClass]
    99  public class EnumDecomposer : IDecomposer {
     
    3030      return Enum.Parse(t, (string)it.Current.Value);
    3131    }
    32    
    33     public void Populate(object instance, IEnumerable<Tag> elements, Type t) {     
     32
     33    public void Populate(object instance, IEnumerable<Tag> elements, Type t) {
    3434    }
    3535  }
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/EnumerableDecomposer.cs

    r1563 r1566  
    66using System.Collections.Generic;
    77
    8 namespace HeuristicLab.Persistence.Default.Decomposers { 
     8namespace HeuristicLab.Persistence.Default.Decomposers {
    99
    1010  [EmptyStorableClass]
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/KeyValuePairDecomposer.cs

    r1563 r1566  
    77
    88namespace HeuristicLab.Persistence.Default.Decomposers {
    9  
     9
    1010  [EmptyStorableClass]
    1111  public class KeyValuePairDecomposer : IDecomposer {
     
    1818    public bool CanDecompose(Type type) {
    1919      return type.IsGenericType &&
    20              type.GetGenericTypeDefinition() == 
    21              typeof (KeyValuePair<int, int>).GetGenericTypeDefinition();
     20             type.GetGenericTypeDefinition() ==
     21             typeof(KeyValuePair<int, int>).GetGenericTypeDefinition();
    2222    }
    2323
     
    3838    public void Populate(object instance, IEnumerable<Tag> o, Type t) {
    3939      IEnumerator<Tag> iter = o.GetEnumerator();
    40       iter.MoveNext();     
     40      iter.MoveNext();
    4141      t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
    4242        .Single(fi => fi.Name == "key").SetValue(instance, iter.Current.Value);
    4343      iter.MoveNext();
    4444      t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
    45         .Single(fi => fi.Name == "value").SetValue(instance, iter.Current.Value);     
     45        .Single(fi => fi.Name == "value").SetValue(instance, iter.Current.Value);
    4646    }
    4747  }
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/StorableDecomposer.cs

    r1563 r1566  
    3434    }
    3535
    36     public void Populate(object instance, IEnumerable<Tag> objects, Type type) {           
    37       var memberDict = new Dictionary<string, Tag>();     
    38       IEnumerator<Tag> iter = objects.GetEnumerator();     
     36    public void Populate(object instance, IEnumerable<Tag> objects, Type type) {
     37      var memberDict = new Dictionary<string, Tag>();
     38      IEnumerator<Tag> iter = objects.GetEnumerator();
    3939      while (iter.MoveNext()) {
    4040        memberDict.Add(iter.Current.Name, iter.Current);
    41       }     
     41      }
    4242      foreach (var mapping in StorableAttribute.GetStorableAccessors(instance)) {
    4343        if (memberDict.ContainsKey(mapping.Key)) {
    44           mapping.Value.Set(memberDict[mapping.Key].Value);         
     44          mapping.Value.Set(memberDict[mapping.Key].Value);
    4545        } else if (mapping.Value.DefaultValue != null) {
    4646          mapping.Value.Set(mapping.Value.DefaultValue);
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/TypeDecomposer.cs

    r1563 r1566  
    55
    66namespace HeuristicLab.Persistence.Default.Decomposers {
    7  
     7
    88  [EmptyStorableClass]
    99  public class TypeDecomposer : IDecomposer {
     
    1414
    1515    public bool CanDecompose(Type type) {
    16       return type == typeof (Type) ||
     16      return type == typeof(Type) ||
    1717             type.VersionInvariantName() == "System.RuntimeType, mscorlib";
    1818    }
     
    3030        return Type.GetType((string)typeName.Value);
    3131      }
    32       return null;     
     32      return null;
    3333    }
    3434
    35     public void Populate(object instance, IEnumerable<Tag> objects, Type type) {     
     35    public void Populate(object instance, IEnumerable<Tag> objects, Type type) {
    3636    }
    3737  }
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/X2StringDecomposer.cs

    r1563 r1566  
    99namespace HeuristicLab.Persistence.Default.Decomposers {
    1010
    11   public class Number2StringConverter {   
     11  public class Number2StringConverter {
    1212
    1313    private static readonly List<Type> numberTypes =
     
    2727      };
    2828
    29     private static readonly Dictionary<Type, MethodInfo> numberParsers; 
     29    private static readonly Dictionary<Type, MethodInfo> numberParsers;
    3030
    3131    static Number2StringConverter() {
    3232      numberParsers = new Dictionary<Type, MethodInfo>();
    33       foreach ( var type in numberTypes ) {
     33      foreach (var type in numberTypes) {
    3434        numberParsers[type] = type
    3535          .GetMethod("Parse", BindingFlags.Static | BindingFlags.Public,
    36                      null, new[] {typeof (string)}, null);         
     36                     null, new[] { typeof(string) }, null);
    3737      }
    3838    }
     
    4343
    4444    public string Format(object obj) {
    45       if (obj.GetType() == typeof(float))       
     45      if (obj.GetType() == typeof(float))
    4646        return ((float)obj).ToString("r", CultureInfo.InvariantCulture);
    4747      if (obj.GetType() == typeof(double))
     
    5151      return obj.ToString();
    5252    }
    53    
     53
    5454    public object Parse(string stringValue, Type type) {
    5555      return numberParsers[type]
    5656        .Invoke(null,
    5757            BindingFlags.Static | BindingFlags.PutRefDispProperty,
    58                   null, new[] {stringValue}, CultureInfo.InvariantCulture);
    59     }
    60 
    61   } 
     58                  null, new[] { stringValue }, CultureInfo.InvariantCulture);
     59    }
     60
     61  }
    6262
    6363  [EmptyStorableClass]
     
    8888    }
    8989
    90     public void Populate(object instance, IEnumerable<Tag> tags, Type type) {     
    91     }
    92 
    93   } 
     90    public void Populate(object instance, IEnumerable<Tag> tags, Type type) {
     91    }
     92
     93  }
    9494
    9595  [EmptyStorableClass]
     
    9999      get { return 200; }
    100100    }
    101    
     101
    102102    private static readonly Number2StringConverter numberConverter =
    103       new Number2StringConverter();   
     103      new Number2StringConverter();
    104104
    105105    public bool CanDecompose(Type type) {
    106106      return
    107         (type.IsArray || type == typeof (Array)) &&
     107        (type.IsArray || type == typeof(Array)) &&
    108108        numberConverter.CanDecompose(type.GetElementType());
    109109    }
     
    146146      var tagIter = metaInfo.GetEnumerator();
    147147      tagIter.MoveNext();
    148       var valueIter = ((string) tagIter.Current.Value)
    149         .Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries)
     148      var valueIter = ((string)tagIter.Current.Value)
     149        .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
    150150        .GetEnumerator();
    151151      valueIter.MoveNext();
    152       int rank = int.Parse((string) valueIter.Current);     
     152      int rank = int.Parse((string)valueIter.Current);
    153153      int[] lengths = new int[rank];
    154       int[] lowerBounds = new int[rank];     
     154      int[] lowerBounds = new int[rank];
    155155      for (int i = 0; i < rank; i++) {
    156156        valueIter.MoveNext();
    157         lengths[i] = int.Parse((string) valueIter.Current);       
    158       }     
     157        lengths[i] = int.Parse((string)valueIter.Current);
     158      }
    159159      for (int i = 0; i < rank; i++) {
    160160        valueIter.MoveNext();
    161         lowerBounds[i] = int.Parse((string) valueIter.Current);       
     161        lowerBounds[i] = int.Parse((string)valueIter.Current);
    162162      }
    163163      Type elementType = type.GetElementType();
    164164      Array a = Array.CreateInstance(elementType, lengths, lowerBounds);
    165       int[] positions = (int[]) lowerBounds.Clone();
     165      int[] positions = (int[])lowerBounds.Clone();
    166166      while (valueIter.MoveNext()) {
    167167        a.SetValue(
    168           numberConverter.Parse((string)valueIter.Current, elementType),         
     168          numberConverter.Parse((string)valueIter.Current, elementType),
    169169          positions);
    170170        positions[0] += 1;
    171         for ( int i = 0; i<rank-1; i++ ) {
     171        for (int i = 0; i < rank - 1; i++) {
    172172          if (positions[i] >= lengths[i] + lowerBounds[i]) {
    173173            positions[i + 1] += 1;
     
    195195    private static readonly Number2StringConverter numberConverter =
    196196      new Number2StringConverter();
    197    
     197
    198198    private static readonly Dictionary<Type, Type> interfaceCache = new Dictionary<Type, Type>();
    199199
     
    212212      return null;
    213213    }
    214    
     214
    215215    public bool ImplementsGenericEnumerable(Type type) {
    216216      return GetGenericEnumerableInterface(type) != null;
     
    225225          BindingFlags.NonPublic |
    226226          BindingFlags.Instance,
    227           null, Type.EmptyTypes, null) != null;     
     227          null, Type.EmptyTypes, null) != null;
    228228    }
    229229
     
    240240    public IEnumerable<Tag> Decompose(object obj) {
    241241      Type type = obj.GetType();
    242       Type enumerable = GetGenericEnumerableInterface(type);     
    243       InterfaceMapping iMap = obj.GetType().GetInterfaceMap(enumerable);     
     242      Type enumerable = GetGenericEnumerableInterface(type);
     243      InterfaceMapping iMap = obj.GetType().GetInterfaceMap(enumerable);
    244244      MethodInfo getEnumeratorMethod =
    245245        iMap.TargetMethods[
     
    247247          iMap.InterfaceMethods,
    248248          enumerable.GetMethod("GetEnumerator"))];
    249       object[] empty = new object[] {};
     249      object[] empty = new object[] { };
    250250      object genericEnumerator = getEnumeratorMethod.Invoke(obj, empty);
    251251      MethodInfo moveNextMethod = genericEnumerator.GetType().GetMethod("MoveNext");
    252252      PropertyInfo currentProperty = genericEnumerator.GetType().GetProperty("Current");
    253253      StringBuilder sb = new StringBuilder();
    254       while ( (bool)moveNextMethod.Invoke(genericEnumerator, empty) )
     254      while ((bool)moveNextMethod.Invoke(genericEnumerator, empty))
    255255        sb.Append(
    256256          numberConverter.Format(
     
    265265    public void Populate(object instance, IEnumerable<Tag> tags, Type type) {
    266266      Type enumerable = GetGenericEnumerableInterface(type);
    267       Type elementType = enumerable.GetGenericArguments()[0];     
    268       MethodInfo addMethod = type.GetMethod("Add");     
     267      Type elementType = enumerable.GetGenericArguments()[0];
     268      MethodInfo addMethod = type.GetMethod("Add");
    269269      var tagEnumerator = tags.GetEnumerator();
    270270      tagEnumerator.MoveNext();
    271       string[] stringValues = ((string) tagEnumerator.Current.Value)
    272         .Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries);
     271      string[] stringValues = ((string)tagEnumerator.Current.Value)
     272        .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
    273273      foreach (var value in stringValues) {
    274         addMethod.Invoke(instance, new[] {numberConverter.Parse(value, elementType)});
     274        addMethod.Invoke(instance, new[] { numberConverter.Parse(value, elementType) });
    275275      }
    276276    }
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/ViewOnly/ViewOnlyFormat.cs

    r1564 r1566  
    1717
    1818  public class ViewOnlyFormat : FormatBase<String> {
    19     public override string Name { get { return "ViewOnly"; } }   
     19    public override string Name { get { return "ViewOnly"; } }
    2020  }
    2121
     
    4747  [EmptyStorableClass]
    4848  public class Float2ViewFormatter : ValueType2ViewFormatterBase<float> { }
    49    
     49
    5050  public class ViewOnlyGenerator : GeneratorBase<string> {
    5151
     
    5858      isSepReq = false;
    5959      this.showRefs = showRefs;
    60     }   
     60    }
    6161
    6262    protected override string Format(BeginToken beginToken) {
    63       StringBuilder sb = new StringBuilder();     
     63      StringBuilder sb = new StringBuilder();
    6464      if (isSepReq)
    6565        sb.Append(", ");
    66       if ( ! string.IsNullOrEmpty(beginToken.Name) ) {
     66      if (!string.IsNullOrEmpty(beginToken.Name)) {
    6767        sb.Append(beginToken.Name);
    68         if ( beginToken.Id != null && showRefs ) {
     68        if (beginToken.Id != null && showRefs) {
    6969          sb.Append('[');
    7070          sb.Append(beginToken.Id);
    7171          sb.Append(']');
    72         }       
     72        }
    7373      }
    7474      sb.Append("(");
     
    7878
    7979    protected override string Format(EndToken endToken) {
    80       isSepReq = true;     
     80      isSepReq = true;
    8181      return ")";
    8282    }
    8383
    8484    protected override string Format(PrimitiveToken primitiveToken) {
    85       StringBuilder sb = new StringBuilder();     
     85      StringBuilder sb = new StringBuilder();
    8686      if (isSepReq)
    8787        sb.Append(", ");
    88       if ( ! string.IsNullOrEmpty(primitiveToken.Name) ) {
     88      if (!string.IsNullOrEmpty(primitiveToken.Name)) {
    8989        sb.Append(primitiveToken.Name);
    90         if ( primitiveToken.Id != null && showRefs ) {
     90        if (primitiveToken.Id != null && showRefs) {
    9191          sb.Append('[');
    9292          sb.Append(primitiveToken.Id);
     
    9696      }
    9797      sb.Append(((String)primitiveToken.SerialData).Data);
    98       isSepReq = true;     
    99       return sb.ToString(); 
     98      isSepReq = true;
     99      return sb.ToString();
    100100    }
    101101
     
    104104      if (isSepReq)
    105105        sb.Append(", ");
    106       if ( ! string.IsNullOrEmpty(referenceToken.Name) ) {
     106      if (!string.IsNullOrEmpty(referenceToken.Name)) {
    107107        sb.Append(referenceToken.Name);
    108108        sb.Append('=');
     
    111111      sb.Append(referenceToken.Id);
    112112      sb.Append('}');
    113       isSepReq = true;     
     113      isSepReq = true;
    114114      return sb.ToString();
    115115    }
     
    141141
    142142    public static string Serialize(object o, Configuration configuration) {
    143       Serializer s = new Serializer(o, configuration);     
     143      Serializer s = new Serializer(o, configuration);
    144144      ViewOnlyGenerator generator = new ViewOnlyGenerator();
    145145      StringBuilder sb = new StringBuilder();
    146146      foreach (ISerializationToken token in s) {
    147         sb.Append(generator.Format(token));       
     147        sb.Append(generator.Format(token));
    148148      }
    149149      return sb.ToString();
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleArray2XmlFormatters.cs

    r1564 r1566  
    44
    55namespace HeuristicLab.Persistence.Default.Xml.Compact {
    6  
     6
    77  public abstract class DoubleArray2XmlFormatterBase<T> : NumberArray2XmlFormatterBase<T> {
    8    
     8
    99    protected override string FormatValue(object o) {
    1010      return ((double)o).ToString("r", CultureInfo.InvariantCulture);
     
    2424
    2525  [EmptyStorableClass]
    26   public class Double3DArray2XmlFormatter : DoubleArray2XmlFormatterBase<double[,,]> { }
    27  
     26  public class Double3DArray2XmlFormatter : DoubleArray2XmlFormatterBase<double[, ,]> { }
     27
    2828}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleList2XmlFormatter.cs

    r1564 r1566  
    88
    99  [EmptyStorableClass]
    10   public class DoubleList2XmlFormatter : NumberEnumeration2XmlFormatterBase<List<double>> {   
     10  public class DoubleList2XmlFormatter : NumberEnumeration2XmlFormatterBase<List<double>> {
    1111
    1212    protected override void Add(IEnumerable enumeration, object o) {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/IntArray2XmlFormatters.cs

    r1564 r1566  
    33
    44namespace HeuristicLab.Persistence.Default.Xml.Compact {
    5  
    6   public abstract class IntArray2XmlFormatterBase<T> : NumberArray2XmlFormatterBase<T> {   
     5
     6  public abstract class IntArray2XmlFormatterBase<T> : NumberArray2XmlFormatterBase<T> {
    77
    88    protected override string FormatValue(object o) {
     
    2222
    2323  [EmptyStorableClass]
    24   public class Int3DArray2XmlFormatter : IntArray2XmlFormatterBase<int[,,]> { }
    25  
     24  public class Int3DArray2XmlFormatter : IntArray2XmlFormatterBase<int[, ,]> { }
     25
    2626}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/IntList2XmlFormatter.cs

    r1564 r1566  
    88  [EmptyStorableClass]
    99  public class IntList2XmlFormatter : NumberEnumeration2XmlFormatterBase<List<int>> {
    10    
     10
    1111    protected override void Add(IEnumerable enumeration, object o) {
    1212      ((List<int>)enumeration).Add((int)o);
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/NumberArray2XmlFormatterBase.cs

    r1564 r1566  
    55
    66namespace HeuristicLab.Persistence.Default.Xml.Compact {
    7                                                              
     7
    88  public abstract class NumberArray2XmlFormatterBase<T> : FormatterBase<T, XmlString> {
    99
     
    3030      }
    3131      int[] positions = (int[])lowerBounds.Clone();
    32       while (positions[a.Rank - 1] < lengths[a.Rank - 1] + lowerBounds[a.Rank - 1]) {       
     32      while (positions[a.Rank - 1] < lengths[a.Rank - 1] + lowerBounds[a.Rank - 1]) {
    3333        sb.Append(Separator);
    3434        sb.Append(FormatValue(a.GetValue(positions)));
     
    4242          }
    4343        }
    44       }     
     44      }
    4545      return new XmlString(sb.ToString());
    4646    }
     
    8080    }
    8181  }
    82  
     82
    8383}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/NumberEnumeration2XmlFormatterBase.cs

    r1564 r1566  
    55
    66namespace HeuristicLab.Persistence.Default.Xml.Compact {
    7  
     7
    88  public abstract class NumberEnumeration2XmlFormatterBase<T> : FormatterBase<T, XmlString> where T : IEnumerable {
    99
     
    3232    }
    3333  }
    34  
     34
    3535}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Bool2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8  
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  [EmptyStorableClass]
    1010  public class Bool2XmlFormatter : SimpleNumber2XmlFormatterBase<bool> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Byte2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8  
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  [EmptyStorableClass]
    1010  public class Byte2XmlFormatter : SimpleNumber2XmlFormatterBase<byte> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/DateTime2XmlFormatter.cs

    r1564 r1566  
    66
    77  [EmptyStorableClass]
    8   public class DateTime2XmlFormatter : FormatterBase<DateTime, XmlString> {   
    9    
     8  public class DateTime2XmlFormatter : FormatterBase<DateTime, XmlString> {
     9
    1010    public override XmlString Format(DateTime dt) {
    11       return new XmlString(dt.Ticks.ToString());     
     11      return new XmlString(dt.Ticks.ToString());
    1212    }
    1313
     
    1818  }
    1919
    20  
     20
    2121}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Decimal2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8  
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  [EmptyStorableClass]
    1010  public class Decimal2XmlFormatter : DecimalNumber2XmlFormatterBase<decimal> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/DecimalNumber2XmlFormatterBase.cs

    r1564 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8  
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  public abstract class DecimalNumber2XmlFormatterBase<T> : FormatterBase<T, XmlString> {
    10    
     10
    1111    private static MethodInfo ToStringMethod = typeof(T)
    1212      .GetMethod(
     
    3030      return new XmlString((string)ToStringMethod.Invoke(t, new object[] { "r", CultureInfo.InvariantCulture }));
    3131    }
    32     public override T Parse(XmlString x) {     
     32    public override T Parse(XmlString x) {
    3333      return (T)ParseMethod.Invoke(null, new object[] { x.Data, CultureInfo.InvariantCulture });
    3434    }
    35   } 
     35  }
    3636}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Double2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8    
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  [EmptyStorableClass]
    1010  public class Double2XmlFormatter : DecimalNumber2XmlFormatterBase<double> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Float2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8    
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  [EmptyStorableClass]
    1010  public class Float2XmlFormatter : DecimalNumber2XmlFormatterBase<float> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Int2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
    88
    99  [EmptyStorableClass]
    1010  public class Int2XmlFormatter : SimpleNumber2XmlFormatterBase<int> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Long2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
    88
    99  [EmptyStorableClass]
    1010  public class Long2XmlFormatter : SimpleNumber2XmlFormatterBase<long> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/SByte2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8  
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  [EmptyStorableClass]
    1010  public class Sbyte2XmlFormatter : SimpleNumber2XmlFormatterBase<sbyte> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Short2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8  
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  [EmptyStorableClass]
    1010  public class Short2XmlFormatter : SimpleNumber2XmlFormatterBase<short> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/SimpleNumber2XmlFormatterBase.cs

    r1564 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
    88
    99  public abstract class SimpleNumber2XmlFormatterBase<T> : FormatterBase<T, XmlString> {
     
    2222    }
    2323    public override T Parse(XmlString x) {
    24       return (T)ParseMethod.Invoke(null, new[] { x.Data });     
     24      return (T)ParseMethod.Invoke(null, new[] { x.Data });
    2525    }
    26   } 
     26  }
    2727}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/String2XmlFormatter.cs

    r1564 r1566  
    99  [EmptyStorableClass]
    1010  public class String2XmlFormatter : FormatterBase<string, XmlString> {
    11    
     11
    1212    public override XmlString Format(string s) {
    1313      StringBuilder sb = new StringBuilder();
     
    1515      sb.Append(s.Replace("]]>", "]]]]><![CDATA[>"));
    1616      sb.Append("]]>");
    17       return new XmlString(sb.ToString()); 
     17      return new XmlString(sb.ToString());
    1818    }
    1919
     
    2222    public override string Parse(XmlString x) {
    2323      StringBuilder sb = new StringBuilder();
    24       foreach (string s in x.Data.Split(separators,       
     24      foreach (string s in x.Data.Split(separators,
    2525        StringSplitOptions.RemoveEmptyEntries)) {
    2626        sb.Append(s);
     
    2828      return sb.ToString();
    2929    }
    30   } 
     30  }
    3131}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/UInt2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8  
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  [EmptyStorableClass]
    1010  public class UInt2XmlFormatter : SimpleNumber2XmlFormatterBase<uint> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/ULong2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8  
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  [EmptyStorableClass]
    10   public class ULong2XmlFormatter : SimpleNumber2XmlFormatterBase<ulong> { } 
    11  
     10  public class ULong2XmlFormatter : SimpleNumber2XmlFormatterBase<ulong> { }
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/UShort2XmlFormatter.cs

    r1554 r1566  
    55using System.Globalization;
    66
    7 namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    8  
     7namespace HeuristicLab.Persistence.Default.Xml.Primitive {
     8
    99  [EmptyStorableClass]
    1010  public class UShort2XmlFormatter : SimpleNumber2XmlFormatterBase<ushort> { }
    11  
     11
    1212}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlFormat.cs

    r1564 r1566  
    66  [EmptyStorableClass]
    77  public class XmlFormat : FormatBase<XmlString> {
    8     public override string Name { get { return "XML"; } }   
     8    public override string Name { get { return "XML"; } }
    99  }
    1010
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs

    r1564 r1566  
    2121    public const string METAINFO = "METAINFO";
    2222  }
    23  
     23
    2424  public class XmlGenerator : GeneratorBase<string> {
    25    
     25
    2626    private int depth;
    2727
     
    4545      if (type == NodeType.End)
    4646        sb.Append('/');
    47       sb.Append(name);     
     47      sb.Append(name);
    4848      foreach (var attribute in attributes) {
    4949        if (attribute.Value != null && !string.IsNullOrEmpty(attribute.Value.ToString())) {
     
    5858        sb.Append('/');
    5959      sb.Append(">");
    60       return sb.ToString();     
     60      return sb.ToString();
    6161    }
    6262
     
    6565    }
    6666
    67     protected override string Format(BeginToken beginToken) {           
     67    protected override string Format(BeginToken beginToken) {
    6868      var attributes = new Dictionary<string, object> {
    6969        {"name", beginToken.Name},
     
    7676    }
    7777
    78     protected override string Format(EndToken endToken) {     
     78    protected override string Format(EndToken endToken) {
    7979      depth -= 1;
    8080      return Prefix + "</" + XmlStrings.COMPOSITE + ">\r\n";
    8181    }
    8282
    83     protected override string Format(PrimitiveToken dataToken) {     
     83    protected override string Format(PrimitiveToken dataToken) {
    8484      var attributes =
    8585        new Dictionary<string, object> {
     
    8989      return Prefix +
    9090        FormatNode(XmlStrings.PRIMITIVE, attributes, NodeType.Start) +
    91         ((XmlString)dataToken.SerialData).Data + "</" + XmlStrings.PRIMITIVE + ">\r\n";     
     91        ((XmlString)dataToken.SerialData).Data + "</" + XmlStrings.PRIMITIVE + ">\r\n";
    9292    }
    9393
    94     protected override string Format(ReferenceToken refToken) {     
     94    protected override string Format(ReferenceToken refToken) {
    9595      var attributes = new Dictionary<string, object> {
    9696        {"ref", refToken.Id},
    97         {"name", refToken.Name}};                                       
    98       return Prefix + FormatNode(XmlStrings.REFERENCE, attributes, NodeType.Inline) + "\r\n"; 
     97        {"name", refToken.Name}};
     98      return Prefix + FormatNode(XmlStrings.REFERENCE, attributes, NodeType.Inline) + "\r\n";
    9999    }
    100100
    101     protected override string Format(NullReferenceToken nullRefToken) {     
     101    protected override string Format(NullReferenceToken nullRefToken) {
    102102      var attributes = new Dictionary<string, object>{
    103         {"name", nullRefToken.Name}};     
     103        {"name", nullRefToken.Name}};
    104104      return Prefix + FormatNode(XmlStrings.NULL, attributes, NodeType.Inline) + "\r\n";
    105105    }
     
    127127    }
    128128
    129     public static void Serialize(object o, string filename) {     
     129    public static void Serialize(object o, string filename) {
    130130      Serialize(o, filename, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));
    131131    }
     
    135135      XmlGenerator generator = new XmlGenerator();
    136136      ZipOutputStream zipStream = new ZipOutputStream(File.Create(filename));
    137       zipStream.SetLevel(9);     
    138       zipStream.PutNextEntry(new ZipEntry("data.xml"));     
     137      zipStream.SetLevel(9);
     138      zipStream.PutNextEntry(new ZipEntry("data.xml"));
    139139      StreamWriter writer = new StreamWriter(zipStream);
    140       ILog logger = Logger.GetDefaultLogger();     
     140      ILog logger = Logger.GetDefaultLogger();
    141141      foreach (ISerializationToken token in serializer) {
    142142        string line = generator.Format(token);
     
    151151        logger.Debug(line);
    152152      }
    153       writer.Flush();           
    154       zipStream.Close();     
     153      writer.Flush();
     154      zipStream.Close();
    155155    }
    156156
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs

    r1564 r1566  
    1919    public XmlParser(TextReader input) {
    2020      XmlReaderSettings settings = new XmlReaderSettings {
    21                                        ConformanceLevel = ConformanceLevel.Document,
    22                                        IgnoreWhitespace = true,
    23                                        IgnoreComments = true
    24                                      };
     21        ConformanceLevel = ConformanceLevel.Document,
     22        IgnoreWhitespace = true,
     23        IgnoreComments = true
     24      };
    2525      reader = XmlReader.Create(input, settings);
    2626      handlers = new Dictionary<string, Handler> {
     
    6666
    6767    private IEnumerator<ISerializationToken> ParseComposite() {
    68       string name = reader.GetAttribute("name");           
     68      string name = reader.GetAttribute("name");
    6969      string idString = reader.GetAttribute("id");
    7070      int? id = null;
     
    104104      var typeCache = new List<TypeMapping>();
    105105      XmlReader xmlReader = XmlReader.Create(reader);
    106       while ( xmlReader.Read() ) {
     106      while (xmlReader.Read()) {
    107107        if (xmlReader.Name == XmlStrings.TYPE) {
    108108          typeCache.Add(new TypeMapping(
     
    116116
    117117    public static object DeSerialize(string filename) {
    118       ZipFile zipFile = new ZipFile(filename);     
     118      ZipFile zipFile = new ZipFile(filename);
    119119      Deserializer deSerializer = new Deserializer(
    120120        ParseTypeCache(
     
    123123      XmlParser parser = new XmlParser(
    124124        new StreamReader(zipFile.GetInputStream(zipFile.GetEntry("data.xml"))));
    125       return deSerializer.Deserialize(parser);     
     125      return deSerializer.Deserialize(parser);
    126126    }
    127   } 
     127  }
    128128}
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlString.cs

    r1564 r1566  
    33
    44namespace HeuristicLab.Persistence.Default.Xml {
    5  
     5
    66  public class XmlString : ISerialData {
    77
  • trunk/sources/HeuristicLab.Persistence/3.3/HeuristicLabPersistencePlugin.cs

    r1534 r1566  
    66  [PluginFile(Filename = "HeuristicLab.Persistence-3.3.dll", Filetype = PluginFileType.Assembly)]
    77  [Dependency(Dependency = "HeuristicLab.Tracing-3.2")]
    8   public class HeuristicLabPersistencePlugin : PluginBase {}
     8  public class HeuristicLabPersistencePlugin : PluginBase { }
    99
    1010}
  • trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/IDecomposer.cs

    r1553 r1566  
    4747    /// </summary>   
    4848    void Populate(object instance, IEnumerable<Tag> tags, Type type);
    49   } 
     49  }
    5050
    5151}
  • trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/IFormatter.cs

    r1564 r1566  
    1212    Type SourceType { get; }
    1313    ISerialData Format(object o);
    14     object Parse(ISerialData o); 
     14    object Parse(ISerialData o);
    1515  }
    1616
     
    2323    SerialData Format(Source o);
    2424    Source Parse(SerialData t);
    25   } 
    26      
     25  }
     26
    2727}
  • trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/ISerialData.cs

    r1564 r1566  
    33namespace HeuristicLab.Persistence.Interfaces {
    44
    5  
     5
    66  /// <summary>
    77  /// Marker interface for serialized values generated and parsed by
  • trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/ISerializationToken.cs

    r1562 r1566  
    66  /// deserializer, parser and generator. 
    77  /// </summary>
    8   public interface ISerializationToken {}
    9  
     8  public interface ISerializationToken { }
     9
    1010}
Note: See TracChangeset for help on using the changeset viewer.