Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
trunk/sources/HeuristicLab.Persistence/3.3/Default
Files:
35 edited

Legend:

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