public object GetValue(object parentobject) { if (m_CurrentNode.HasAttribute("Type")) { string type = m_CurrentNode.GetAttribute("Type"); // Get the surrogate for this type IXmlSerializationSurrogate surr = m_SurrogateSelector.GetSurrogate(type); if (null == surr) { throw new ApplicationException(string.Format("Unable to find XmlSurrogate for type {0}!", type)); } else { PushNodeStack(); m_CurrentNode = (XmlElement)m_CurrentNode.FirstChild; object retvalue = surr.Deserialize(null, this, parentobject); PopNodeStack(); m_CurrentNode = (XmlElement)m_CurrentNode.NextSibling; return(retvalue); } } else { throw new ApplicationException(string.Format("Unable to deserialize element {0}, Type attribute missing!", m_CurrentNode.Name)); } }
/// <summary>Deserializes the embedded base type.</summary> /// <param name="instance">The instance of the object to deserialize.</param> /// <param name="fullyQualifiedBaseTypeName">Fully qualified base type name. It is the short name of the assembly, comma, the full type name, comma, and the version. The string must not contain whitespaces. Example: 'AltaxoBase,Altaxo.Main.DocumentPath,0'.</param> /// <param name="parent">The parent object of the current object to deserialize.</param> public object GetBaseValueEmbedded(object instance, string fullyQualifiedBaseTypeName, object parent) { object obj; if ("BaseType" == CurrentElementName) { string basetypestring = _xmlReader.ReadElementString(); IXmlSerializationSurrogate ss = _surrogateSelector.GetSurrogate(basetypestring); if (null == ss) { throw new ArgumentException(string.Format("Type {0} has no XmlSerializationSurrogate to get serialized", fullyQualifiedBaseTypeName)); } obj = ss.Deserialize(instance, this, parent); } else { IXmlSerializationSurrogate ss = _surrogateSelector.GetSurrogate(fullyQualifiedBaseTypeName); if (null == ss) { throw new ArgumentException(string.Format("Type {0} has no XmlSerializationSurrogate to get serialized", fullyQualifiedBaseTypeName)); } obj = ss.Deserialize(instance, this, parent); } return(obj); }
public void GetBaseValueStandalone(string name, object instance, System.Type basetype, object parent) { IXmlSerializationSurrogate ss = m_SurrogateSelector.GetSurrogate(basetype); if (null == ss) { throw new ArgumentException(string.Format("Type {0} has no XmlSerializationSurrogate to get serialized", basetype)); } else { m_Reader.ReadStartElement(); // note: this must now be done by in the deserialization code ss.Deserialize(instance, this, parent); m_Reader.ReadEndElement(); } }
public object GetValue(object parentobject) { string type = m_Reader.GetAttribute("Type"); if (null != type) { if ("UndefinedValue" == type) { m_Reader.Read(); return(null); } // Get the surrogate for this type IXmlSerializationSurrogate surr = m_SurrogateSelector.GetSurrogate(type); if (null == surr) { throw new ApplicationException(string.Format("Unable to find XmlSurrogate for type {0}!", type)); } else { bool bNotEmpty = !m_Reader.IsEmptyElement; // System.Diagnostics.Trace.WriteLine(string.Format("Xml val {0}, type {1}, empty:{2}",m_Reader.Name,type,bNotEmpty)); if (bNotEmpty) { m_Reader.ReadStartElement(); // note: this must now be done by in the deserialization code } object retvalue = surr.Deserialize(null, this, parentobject); if (bNotEmpty) { m_Reader.ReadEndElement(); } else { m_Reader.Read(); } return(retvalue); } } else { throw new ApplicationException(string.Format("Unable to deserialize element at line {0}, position {1}, Type attribute missing!", m_Reader.LineNumber, m_Reader.LinePosition)); } }
public void GetBaseValueEmbedded(object instance, System.Type basetype, object parent) { if ("BaseType" == CurrentElementName) { string basetypestring = m_Reader.ReadElementString(); IXmlSerializationSurrogate ss = m_SurrogateSelector.GetSurrogate(basetypestring); if (null == ss) { throw new ArgumentException(string.Format("Type {0} has no XmlSerializationSurrogate to get serialized", basetype)); } ss.Deserialize(instance, this, parent); } else { IXmlSerializationSurrogate ss = m_SurrogateSelector.GetSurrogate(basetype); if (null == ss) { throw new ArgumentException(string.Format("Type {0} has no XmlSerializationSurrogate to get serialized", basetype)); } ss.Deserialize(instance, this, parent); } }