Changeset 15878
- Timestamp:
- 03/30/18 13:56:55 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCasesPersistenceNew.cs
r15857 r15878 2560 2560 [StorableType("41108958-227D-43C4-B049-80AD0D3DB7F6")] 2561 2561 private class InheritanceB0 : InheritanceA0 { 2562 //[Storable] 2563 //public int x; 2562 [Storable] 2563 public int x; 2564 2565 [StorableConstructor] 2566 private InheritanceB0(StorableConstructorFlag flag) { } 2567 public InheritanceB0(int x) { 2568 this.x = x; 2569 base.x = x; 2570 } 2564 2571 } 2565 2572 … … 2590 2597 private static Dictionary<string, object> ConvertC0_C1(Dictionary<string, object> values) { 2591 2598 var newValues = new Dictionary<string, object>(); 2592 newValues[" 41108958-227D-43C4-B049-80AD0D3DB7F6.x"] = (int)values["41108958-227D-43C4-B049-80AD0D3DB7F6.x"] * 2;2599 newValues["28A5F6B8-49AF-4C6A-AF0E-F92EB4511722.x"] = (int)values["28A5F6B8-49AF-4C6A-AF0E-F92EB4511722.x"] * 2; 2593 2600 return newValues; 2594 2601 } 2602 } 2603 2604 private static class InheritanceConversionsWithNamesDemo { 2605 [StorableConversion("A", 1)] 2606 private static Dictionary<string, object> ConvertA1_A2(Dictionary<string, object> values) { 2607 var newValues = new Dictionary<string, object>(); 2608 newValues["y"] = values["x"]; 2609 return newValues; 2610 } 2611 2612 [StorableConversion("B", 1, baseGuid: "A", baseVersion: 2)] 2613 private static Dictionary<string, object> ConvertB1_B2(Dictionary<string, object> values, out List<Tuple<string, uint>> typeChain) { 2614 typeChain = new List<Tuple<string, uint>> { 2615 Tuple.Create("C", 1u) 2616 }; 2617 2618 var newValues = new Dictionary<string, object>(); 2619 newValues["x"] = values["A.y"]; 2620 newValues["C.x"] = values["A.y"]; 2621 return newValues; 2622 } 2623 2624 [StorableConversion("C", 1)] 2625 private static Dictionary<string, object> ConvertC1_C2(Dictionary<string, object> values) { 2626 var newValues = new Dictionary<string, object>(); 2627 newValues["x"] = (int)values["x"] * 2; 2628 return newValues; 2629 } 2630 2631 [StorableConversion("C", 1, "D", 1)] 2632 [StorableConversion("D", 1, "E", 1)] 2633 private static string Rename() { return "D"; } 2595 2634 } 2596 2635 … … 2600 2639 public void TestInheritanceConversionCase1() { 2601 2640 var test = new Func<InheritanceB0>(() => { 2602 return new InheritanceB0( ) { x = 17 };2641 return new InheritanceB0(17); 2603 2642 }); 2604 2643 … … 2629 2668 var restoredC1 = (InheritanceC1)o; 2630 2669 var restoredB1 = (InheritanceB1)o; 2631 Assert.AreEqual(old.x, restoredB1.x);2632 2670 Assert.AreEqual(old.x * 2, restoredC1.x); 2633 2671 }
Note: See TracChangeset
for help on using the changeset viewer.