Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/07/09 11:34:49 (16 years ago)
Author:
epitzer
Message:

Make serialization order of array components explicit (in all array decomposers) (#574)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/Default/Xml/Compact/NumberArray2XmlFormatters.cs

    r1454 r1518  
    33using HeuristicLab.Persistence.Interfaces;
    44using System;
     5using HeuristicLab.Persistence.Default.ViewOnly;
    56
    67namespace HeuristicLab.Persistence.Default.Xml.Compact {
     
    1617    public object DoFormat(object obj) {
    1718      Array a = (Array)obj;
     19      int[] lengths = new int[a.Rank];
     20      int[] lowerBounds = new int[a.Rank];
    1821      StringBuilder sb = new StringBuilder();
    1922      sb.Append(a.Rank);
     
    2124        sb.Append(Separator);
    2225        sb.Append(a.GetLength(i));
     26        lengths[i] = a.GetLength(i);
    2327      }
    2428      for (int i = 0; i < a.Rank; i++) {
    2529        sb.Append(Separator);
    2630        sb.Append(a.GetLowerBound(i));
     31        lowerBounds[i] = a.GetLowerBound(i);
    2732      }
    28       foreach (object o in a) {
     33      int[] positions = (int[])lowerBounds.Clone();
     34      while (positions[a.Rank - 1] < lengths[a.Rank - 1] + lowerBounds[a.Rank - 1]) {
     35        Console.WriteLine(ViewOnlyGenerator.Serialize(positions));
    2936        sb.Append(Separator);
    30         sb.Append(formatValue(o));
    31       }
     37        sb.Append(formatValue(a.GetValue(positions)));
     38        positions[0] += 1;
     39        for (int i = 0; i < a.Rank - 1; i++) {
     40          if (positions[i] >= lengths[i] + lowerBounds[i]) {
     41            positions[i] = lowerBounds[i];
     42            positions[i + 1] += 1;
     43          } else {
     44            break;
     45          }
     46        }
     47      }     
    3248      return sb.ToString();
    3349    }
Note: See TracChangeset for help on using the changeset viewer.