Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/08/09 17:05:17 (16 years ago)
Author:
epitzer
Message:

Numerous small changes, coding conventions, renames, mini refactoring (#548)

Location:
trunk/sources/HeuristicLab.Persistence/3.3/Core
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Configuration.cs

    r1454 r1542  
    1313    private readonly Dictionary<Type, IDecomposer> decomposerCache;
    1414    [Storable]
    15     public readonly IFormat Format;
     15    public IFormat Format { get; set; }
    1616
    1717    private Configuration() {
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs

    r1539 r1542  
    77using HeuristicLab.Persistence.Interfaces;
    88using HeuristicLab.Tracing;
     9using HeuristicLab.Persistence.Interfaces.Tokens;
    910
    1011namespace HeuristicLab.Persistence.Core {
     
    1415    private static ConfigurationService instance;
    1516    private readonly Dictionary<IFormat, Configuration> customConfigurations;
    16     public readonly Dictionary<IFormat, List<IFormatter>> Formatters;
    17     public readonly List<IDecomposer> Decomposers;
     17    public Dictionary<IFormat, List<IFormatter>> Formatters { get; private set; }
     18    public List<IDecomposer> Decomposers { get; private set; }
    1819   
    1920    public static ConfigurationService Instance {
     
    2526    }
    2627
    27     public ConfigurationService() {
     28    private ConfigurationService() {
    2829      Formatters = new Dictionary<IFormat, List<IFormatter>>();
    2930      Decomposers = new List<IDecomposer>();
     
    3536    public void LoadSettings() {
    3637      try {
    37         if (String.IsNullOrEmpty(Properties.Settings.Default.customConfigurations) ||
    38           String.IsNullOrEmpty(Properties.Settings.Default.customConfigurationsTypeCache))
     38        if (String.IsNullOrEmpty(Properties.Settings.Default.CustomConfigurations) ||
     39          String.IsNullOrEmpty(Properties.Settings.Default.CustomConfigurationsTypeCache))
    3940          return;
    40         DeSerializer deSerializer = new DeSerializer(
     41        Deserializer deSerializer = new Deserializer(
    4142          XmlParser.ParseTypeCache(
    4243          new StringReader(
    43             Properties.Settings.Default.customConfigurationsTypeCache)));
     44            Properties.Settings.Default.CustomConfigurationsTypeCache)));
    4445        XmlParser parser = new XmlParser(
    4546          new StringReader(
    46             Properties.Settings.Default.customConfigurations));
     47            Properties.Settings.Default.CustomConfigurations));
    4748        var newCustomConfigurations = (Dictionary<IFormat, Configuration>)
    48           deSerializer.DeSerialize(parser);
     49          deSerializer.Deserialize(parser);
    4950        foreach (var config in newCustomConfigurations) {
    5051          customConfigurations[config.Key] = config.Value;
     
    6869      foreach (string s in generator.Format(serializer.TypeCache))
    6970        configurationTypeCacheString.Append(s);
    70       Properties.Settings.Default.customConfigurations =
     71      Properties.Settings.Default.CustomConfigurations =
    7172        configurationString.ToString();
    72       Properties.Settings.Default.customConfigurationsTypeCache =
     73      Properties.Settings.Default.CustomConfigurationsTypeCache =
    7374        configurationTypeCacheString.ToString();
    7475      Properties.Settings.Default.Save();
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/DataMemberAccessor.cs

    r1454 r1542  
    1616    public DataMemberAccessor(
    1717        MemberInfo memberInfo,
    18         StorableAttribute autoStorableAttribute,
     18        StorableAttribute storableAttribute,
    1919        object obj) {
    2020      if (memberInfo.MemberType == MemberTypes.Field) {
     
    3434                "The Storable attribute can only be applied to fields and properties.");
    3535      }
    36       Name = autoStorableAttribute.Name ?? memberInfo.Name;
    37       DefaultValue = autoStorableAttribute.DefaultValue;
     36      Name = storableAttribute.Name ?? memberInfo.Name;
     37      DefaultValue = storableAttribute.DefaultValue;
    3838    }
    3939
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/DeSerializer.cs

    r1494 r1542  
    22using System;
    33using HeuristicLab.Persistence.Interfaces;
     4using HeuristicLab.Persistence.Interfaces.Tokens;
    45
    56namespace HeuristicLab.Persistence.Core { 
    67
    7   public struct ParentReference {} 
     8  public class ParentReference {} 
    89
    910  class CompositeObject {
     
    1819
    1920    public void AddValue(string name, object value, List<Thunk> finalFixes) {
    20       Tag t = new Tag(name, value) {finalFixes = finalFixes};
     21      Tag t = new Tag(name, value) {globalFinalFixes = finalFixes};
    2122      customValues.Add(t);
    2223    }
     
    3031  public delegate void Thunk();
    3132
    32   public class DeSerializer {
     33  public class Deserializer {
    3334   
    3435    private readonly Dictionary<int, object> id2obj;
     
    3839    private List<Thunk> finalFixes;
    3940
    40     public DeSerializer(
     41    public Deserializer(
    4142      IEnumerable<TypeMapping> typeCache) {     
    4243      id2obj = new Dictionary<int, object>();
    4344      parentStack = new Stack<CompositeObject>();
    4445      typeIds = new Dictionary<int, Type>();
    45       serializerMapping = createSerializers(typeCache);
     46      serializerMapping = CreateSerializers(typeCache);
    4647    }
    4748
    48     private Dictionary<Type, object> createSerializers(IEnumerable<TypeMapping> typeCache) {
     49    private Dictionary<Type, object> CreateSerializers(IEnumerable<TypeMapping> typeCache) {
    4950      var map = new Dictionary<Type, object>();
    5051      foreach (var typeMapping in typeCache) {
     
    5960    }
    6061
    61     public object DeSerialize(IEnumerable<ISerializationToken> tokens) {
     62    public object Deserialize(IEnumerable<ISerializationToken> tokens) {
    6263      finalFixes = new List<Thunk>();     
    6364      foreach (ISerializationToken token in tokens) {
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Serializer.cs

    r1454 r1542  
    33using System;
    44using HeuristicLab.Persistence.Interfaces;
     5using HeuristicLab.Persistence.Interfaces.Tokens;
    56
    67namespace HeuristicLab.Persistence.Core {
     
    4950
    5051    public IEnumerator<ISerializationToken> GetEnumerator() {
    51       DataMemberAccessor rootAccessor = new DataMemberAccessor(
    52         rootName, null, () => obj, null);
    53       IEnumerator<ISerializationToken> iterator = Serialize(rootAccessor);
    54       while (iterator.MoveNext())
    55         yield return iterator.Current;     
     52      return Serialize(new DataMemberAccessor(rootName, null, () => obj, null));
    5653    }
    5754   
     
    7572      IDecomposer decomposer = configuration.GetDecomposer(value.GetType());
    7673      if (decomposer != null)
    77         return CompositeEnumerator(accessor.Name, decomposer.DeCompose(value), id, typeId);                 
     74        return CompositeEnumerator(accessor.Name, decomposer.Decompose(value), id, typeId);                 
    7875      throw new ApplicationException(
    7976          String.Format(
     
    9289    private IEnumerator<ISerializationToken> PrimitiveEnumerator(string name,
    9390        int typeId, object serializedValue, int? id) {
    94       yield return new PrimitiveToken(name, typeId, serializedValue, id);
     91      yield return new PrimitiveToken(name, typeId, id, serializedValue);
    9592    }
    9693
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Tag.cs

    r1454 r1542  
    44
    55  public class Tag {
    6     public List<Thunk> finalFixes;
     6    internal List<Thunk> globalFinalFixes; // reference to final fixes of Deserializer
    77    public string Name { get; private set; }
    8     public object Value;      
     8    public object Value { get; set; }     
    99
    1010    public Tag(string name, object value) {
     
    1717    }
    1818    public void SafeSet(Setter setter) {
    19       if ( Value != null && Value.GetType() == typeof(ParentReference))
    20         finalFixes.Add(() => setter(Value));
     19      if ( Value as ParentReference != null)
     20        globalFinalFixes.Add(() => setter(Value));
    2121      else
    2222        setter(Value);
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/TypeMapping.cs

    r1454 r1542  
    33namespace HeuristicLab.Persistence.Core {
    44
    5   public struct TypeMapping {
     5  public class TypeMapping {
    66    public readonly int Id;
    77    public readonly string TypeName;
Note: See TracChangeset for help on using the changeset viewer.