- Timestamp:
- 04/07/09 11:34:49 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/Default/Xml/Compact/NumberArray2XmlFormatters.cs
r1454 r1518 3 3 using HeuristicLab.Persistence.Interfaces; 4 4 using System; 5 using HeuristicLab.Persistence.Default.ViewOnly; 5 6 6 7 namespace HeuristicLab.Persistence.Default.Xml.Compact { … … 16 17 public object DoFormat(object obj) { 17 18 Array a = (Array)obj; 19 int[] lengths = new int[a.Rank]; 20 int[] lowerBounds = new int[a.Rank]; 18 21 StringBuilder sb = new StringBuilder(); 19 22 sb.Append(a.Rank); … … 21 24 sb.Append(Separator); 22 25 sb.Append(a.GetLength(i)); 26 lengths[i] = a.GetLength(i); 23 27 } 24 28 for (int i = 0; i < a.Rank; i++) { 25 29 sb.Append(Separator); 26 30 sb.Append(a.GetLowerBound(i)); 31 lowerBounds[i] = a.GetLowerBound(i); 27 32 } 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)); 29 36 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 } 32 48 return sb.ToString(); 33 49 }
Note: See TracChangeset
for help on using the changeset viewer.