public object LoadObject(object key) { XmlNode node = m_xmlsc.CurrentNode.SelectSingleNode(key.ToString()); m_xmlsc.PushNode(node); object entryKey = m_xmlsc.LoadObject("key"); object entryVal = m_xmlsc.LoadObject("Value"); m_xmlsc.PopNode(); return(new DictionaryEntry(entryKey, entryVal)); }
public object LoadObject(object key) { XmlNode node = m_xmlsc.CurrentNode.SelectSingleNode(key.ToString()); m_xmlsc.PushNode(node); object target = m_xmlsc.LoadObject("Target"); string method = (string)m_xmlsc.LoadObject("Method"); Delegate del = Delegate.CreateDelegate(m_xmlsc.GetTypeFromNode(node), target, method); m_xmlsc.PopNode(); return(del); }
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 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"); }
public object LoadObject(object key) { XmlNode node = m_xmlsc.CurrentNode.SelectSingleNode(key.ToString()); m_xmlsc.PushNode(node); ArrayList al = new ArrayList(); object tmpCount = m_xmlsc.LoadObject("NumEntries"); int count = (int)tmpCount; for (int i = 0; i < count; i++) { object alval = m_xmlsc.LoadObject("Val_" + i); al.Add(alval); } m_xmlsc.PopNode(); return(al); }
[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); }
public object LoadObject(object key) { XmlNode node = m_xmlsc.CurrentNode.SelectSingleNode(key.ToString()); m_xmlsc.PushNode(node); Hashtable ht = new Hashtable(); object tmpCount = m_xmlsc.LoadObject("NumEntries"); int count = (int)tmpCount; for (int i = 0; i < count; i++) { object dekey = m_xmlsc.LoadObject("Key_" + i); object deval = m_xmlsc.LoadObject("Val_" + i); ht.Add(dekey, deval); } m_xmlsc.PopNode(); return(ht); }
public object LoadObject(object key) { XmlNode node = m_xmlsc.CurrentNode.SelectSingleNode(key.ToString()); m_xmlsc.PushNode(node); Type elementType = (Type)m_xmlsc.LoadObject("ElementType"); int[] lengths; _Debug.Assert(node != null, "node != null"); if (node.SelectSingleNode("Lengths") != null) { lengths = (int[])m_xmlsc.LoadObject("Lengths"); } else { lengths = new int[1]; lengths[0] = (int)m_xmlsc.LoadObject("Length"); } int rank = lengths.Length; Array array = Array.CreateInstance(elementType, lengths); int[] indices = new int[rank]; Array.Clear(array, 0, rank); int ndx = 0; while (ndx < rank) { ndx = 0; string ndxStr = GetNdxString(indices); // The problem comes in in this next line. LoadObject gives an object, array might take a primitive value type. array.SetValue(m_xmlsc.LoadObject(ndxStr), indices); while ((ndx < indices.Length) && (++indices[ndx]) == lengths[ndx]) { indices[ndx] = 0; ndx++; } } m_xmlsc.PopNode(); return(array); }
public object LoadObject(object key) { XmlNode node = m_xmlsc.CurrentNode.SelectSingleNode(key.ToString()); m_xmlsc.PushNode(node); Type type = m_xmlsc.GetTypeFromNode(node); string enumText = (string)m_xmlsc.LoadObject(key); m_xmlsc.PopNode(); return(Enum.Parse(type, enumText, false)); }