Free cookie consent management tool by TermsFeed Policy Generator

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.