Changeset 2873 for trunk/sources
- Timestamp:
- 02/26/10 15:46:10 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Core/DeSerializer.cs
r1859 r2873 117 117 } 118 118 119 private void InstantiateParent() { 120 if (parentStack.Count == 0) 121 return; 122 Midwife m = parentStack.Peek(); 123 if (!m.MetaMode && m.Obj == null) 124 CreateInstance(m); 125 } 126 119 127 private void CompositeStartHandler(BeginToken token) { 128 InstantiateParent(); 120 129 Type type = typeIds[(int)token.TypeId]; 121 130 try { … … 193 202 } else { 194 203 Midwife m = parentStack.Peek(); 195 if (m.MetaMode == false && m.Obj == null) 204 if (m.MetaMode == false && m.Obj == null) { 196 205 CreateInstance(m); 206 } 197 207 m.AddValue(name, value); 198 208 } -
trunk/sources/HeuristicLab.Persistence/UnitTests/UseCases.cs
r2859 r2873 581 581 } 582 582 583 class Child { 584 [Storable] 585 public GrandParent grandParent; 586 } 587 588 class Parent { 589 [Storable] 590 public Child child; 591 } 592 593 class GrandParent { 594 [Storable] 595 public Parent parent; 596 } 597 598 [TestMethod] 599 public void InstantiateParentChainReference() { 600 GrandParent gp = new GrandParent(); 601 gp.parent = new Parent(); 602 gp.parent.child = new Child(); 603 gp.parent.child.grandParent = gp; 604 Assert.AreSame(gp, gp.parent.child.grandParent); 605 XmlGenerator.Serialize(gp, tempFile); 606 GrandParent newGp = (GrandParent)XmlParser.Deserialize(tempFile); 607 Assert.AreSame(newGp, newGp.parent.child.grandParent); 608 } 609 583 610 [ClassInitialize] 584 611 public static void Initialize(TestContext testContext) {
Note: See TracChangeset
for help on using the changeset viewer.