[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 TestPersistenceWaterRestoration() { XmlSerializationContext xsc = new XmlSerializationContext(); xsc.Load(Highpoint.Sage.Utility.DirectoryOperations.GetAppDataDir() + "water.xml"); IMaterial water = (IMaterial)xsc.LoadObject("Water"); Debug.WriteLine(water); }
[TestMethod] public void TestPersistenceChemistryStorage() { BasicReactionSupporter brs = new BasicReactionSupporter(); Initialize(brs); XmlSerializationContext xsc = new XmlSerializationContext(); xsc.StoreObject("Chemistry", brs); xsc.Save(Highpoint.Sage.Utility.DirectoryOperations.GetAppDataDir() + "chemistry.xml"); }
public void SerializeTo(XmlSerializationContext xmlsc) { xmlsc.StoreObject("Child1", m_child1); xmlsc.StoreObject("Child2", m_child2); xmlsc.StoreObject("Name", m_name); xmlsc.StoreObject("Age", m_age); xmlsc.StoreObject("Married", m_married); xmlsc.StoreObject("Birthday", m_birthday); xmlsc.StoreObject("TimeSpan", m_ts); xmlsc.StoreObject("Hashtable", m_ht); xmlsc.StoreObject("ArrayList", m_al); }
public void DeserializeFrom(XmlSerializationContext xmlsc) { m_child1 = (MyTestObject)xmlsc.LoadObject("Child1"); m_child2 = (MyTestObject)xmlsc.LoadObject("Child2"); m_name = (string)xmlsc.LoadObject("Name"); m_age = (double)xmlsc.LoadObject("Age"); m_married = (bool)xmlsc.LoadObject("Married"); m_birthday = (DateTime)xmlsc.LoadObject("Birthday"); m_ts = (TimeSpan)xmlsc.LoadObject("TimeSpan"); m_ht = (Hashtable)xmlsc.LoadObject("Hashtable"); m_al = (ArrayList)xmlsc.LoadObject("ArrayList"); }
[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"); }
public EnumXmlSerializer(XmlSerializationContext xmlsc) { m_xmlsc = xmlsc; }
public BoolXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(bool)) { }
public StringXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(string)) { }
protected PrimitiveXmlSerializer(XmlSerializationContext xmlsc, Type type) { m_xmlsc = xmlsc; m_type = type; }
public HashtableXmlSerializer(XmlSerializationContext xmlsc) { m_xmlsc = xmlsc; }
public ArrayXmlSerializer(XmlSerializationContext xmlsc) { m_xmlsc = xmlsc; }
public DateTimeXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(DateTime)) { }
public TypeXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(Type)) { }
public DictionaryEntryXmlSerializer(XmlSerializationContext xmlsc) { m_xmlsc = xmlsc; }
public TimeSpanXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(TimeSpan)) { }
public DoubleXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(double)) { }
public ByteXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(byte)) { }
public UintXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(uint)) { }
public UShortXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(ushort)) { }
public LongXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(long)) { }
public GuidXmlSerializer(XmlSerializationContext xmlsc) : base(xmlsc, typeof(Guid)) { }
public DelegateXmlSerializer(XmlSerializationContext xmlsc) { m_xmlsc = xmlsc; }