Changeset 1518
- Timestamp:
- 04/07/09 11:34:49 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence.Test/NewSerializationTest.cs
r1494 r1518 243 243 } 244 244 245 public class Base { 246 [Storable] private int baseInt = 3; 247 } 248 249 public class Derived: Base { 250 [Storable] private int derivedInt = 5; 245 public static void Test6() { 246 string[,] mDimString = new string[,] { 247 {"ora", "et", "labora"}, 248 {"Beten", "und", "Arbeiten"} 249 }; 250 XmlGenerator.Serialize(mDimString, "test6.zip"); 251 object o = XmlParser.DeSerialize("test6.zip"); 252 Console.WriteLine(ViewOnlyGenerator.Serialize(mDimString)); 253 Console.WriteLine(ViewOnlyGenerator.Serialize(o)); 251 254 } 252 255 … … 259 262 Test4(); 260 263 Test5(); 264 Test6(); 261 265 //SpeedTest(); 262 266 //SpeedTest2(); -
trunk/sources/HeuristicLab.Persistence/Default/Decomposers/ArrayDecomposer.cs
r1463 r1518 15 15 Array a = (Array)array; 16 16 yield return new Tag("rank", a.Rank); 17 int[] lengths = new int[a.Rank]; 18 int[] lowerBounds = new int[a.Rank]; 17 19 for (int i = 0; i < a.Rank; i++) { 20 lengths[i] = a.GetLength(i); 18 21 yield return new Tag("length_" + i, a.GetLength(i)); 19 22 } 20 23 for (int i = 0; i < a.Rank; i++) { 24 lowerBounds[i] = a.GetLowerBound(i); 21 25 yield return new Tag("lowerBound_" + i, a.GetLowerBound(i)); 22 26 } 23 foreach (object o in (Array)array) { 24 yield return new Tag(null, o); 27 int[] positions = (int[])lowerBounds.Clone(); 28 while (positions[a.Rank - 1] < lengths[a.Rank - 1] + lowerBounds[a.Rank - 1]) { 29 yield return new Tag(a.GetValue(positions)); 30 positions[0] += 1; 31 for (int i = 0; i < a.Rank - 1; i++) { 32 if (positions[i] >= lowerBounds[i] + lengths[i]) { 33 positions[i] = lowerBounds[i]; 34 positions[i + 1] += 1; 35 } else { 36 break; 37 } 38 } 25 39 } 26 40 } -
trunk/sources/HeuristicLab.Persistence/Default/Decomposers/X2StringDecomposer.cs
r1514 r1518 111 111 public IEnumerable<Tag> DeCompose(object obj) { 112 112 Array a = (Array) obj; 113 int[] lengths = new int[a.Rank]; 114 int[] lowerBounds = new int[a.Rank]; 113 115 StringBuilder sb = new StringBuilder(); 114 sb.Append(a.Rank).Append(';'); 115 for ( int i = 0; i<a.Rank; i++ )116 sb.Append(a.Rank).Append(';'); 117 for (int i = 0; i < a.Rank; i++) { 116 118 sb.Append(a.GetLength(i)).Append(';'); 117 for ( int i = 0; i<a.Rank; i++) 119 lengths[i] = a.GetLength(i); 120 } 121 for (int i = 0; i < a.Rank; i++) { 118 122 sb.Append(a.GetLowerBound(i)).Append(';'); 119 foreach (var number in a) { 120 sb.Append(numberDecomposer.Format(number)).Append(';'); 123 lowerBounds[i] = a.GetLowerBound(i); 124 } 125 int[] positions = (int[])lowerBounds.Clone(); 126 while (positions[a.Rank - 1] < lengths[a.Rank - 1] + lowerBounds[a.Rank - 1]) { 127 sb.Append(numberDecomposer.Format(a.GetValue(positions))).Append(';'); 128 positions[0] += 1; 129 for (int i = 0; i < a.Rank - 1; i++) { 130 if (positions[i] >= lengths[i] + lowerBounds[i]) { 131 positions[i] = lowerBounds[i]; 132 positions[i + 1] += 1; 133 } else { 134 break; 135 } 136 } 121 137 } 122 138 yield return new Tag("compact array", sb.ToString()); -
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.