[TestMethod] public void TestPersistenceBasics() { XmlSerializationContext xsc = new XmlSerializationContext(); MyTestObject mto2 = new MyTestObject("Gary", 3.1, null); MyTestObject mto = new MyTestObject("Bill", 6.2, new MyTestObject("Bob", 12.4, new MyTestObject("Steve", 24.8, new MyTestObject("Dave", 48.1, new MyTestObject("Sally", 96.2, new MyTestObject("Rufus", 186.9, null)))))); Debug.WriteLine("Setting " + mto.Child1.Child1.Name + "'s child2 to " + mto2.Name); mto.Child1.Child1.Child2 = mto2; Debug.WriteLine("Setting " + mto.Child1.Name + "'s child2 to " + mto2.Name); mto.Child1.Child2 = mto2; xsc.StoreObject("MTO", mto); xsc.Save(Highpoint.Sage.Utility.DirectoryOperations.GetAppDataDir() + "foo.xml"); xsc.Reset(); xsc.Load(Highpoint.Sage.Utility.DirectoryOperations.GetAppDataDir() + "foo.xml"); MyTestObject mto3 = (MyTestObject)xsc.LoadObject("MTO"); xsc = new XmlSerializationContext(); xsc.StoreObject("MTO", mto3); xsc.Save(Highpoint.Sage.Utility.DirectoryOperations.GetAppDataDir() + "foo2.xml"); }
[TestMethod] public void TestPersistenceWaterStorage() { MaterialType mt = new MaterialType(null, "Water", Guid.NewGuid(), 1.234, 4.05, MaterialState.Liquid, 18.0, 1034); BasicReactionSupporter brs = new BasicReactionSupporter(); brs.MyMaterialCatalog.Add(mt); IMaterial water = mt.CreateMass(1500, 35); XmlSerializationContext xsc = new XmlSerializationContext(); xsc.StoreObject("Water", water); xsc.Save(Highpoint.Sage.Utility.DirectoryOperations.GetAppDataDir() + "water.xml"); xsc.Reset(); xsc.StoreObject("MC", brs.MyMaterialCatalog); xsc.Save(Highpoint.Sage.Utility.DirectoryOperations.GetAppDataDir() + "mc.xml"); }