private IDataNode ReadExtensionDataValue(XmlReaderDelegator xmlReader, string dataContractName, string dataContractNamespace) { this.StartReadExtensionDataValue(xmlReader); if (this.attributes.UnrecognizedAttributesFound) { return(this.ReadUnknownXmlData(xmlReader, dataContractName, dataContractNamespace)); } IDictionary <string, string> namespacesInScope = xmlReader.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml); Read(xmlReader); xmlReader.MoveToContent(); switch (xmlReader.NodeType) { case XmlNodeType.Element: if (!xmlReader.NamespaceURI.StartsWith("http://schemas.datacontract.org/2004/07/", StringComparison.Ordinal)) { return(this.ReadAndResolveUnknownXmlData(xmlReader, namespacesInScope, dataContractName, dataContractNamespace)); } return(this.ReadUnknownClassData(xmlReader, dataContractName, dataContractNamespace)); case XmlNodeType.Text: return(this.ReadPrimitiveExtensionDataValue(xmlReader, dataContractName, dataContractNamespace)); case XmlNodeType.EndElement: { IDataNode node = this.ReadUnknownPrimitiveData(xmlReader, Globals.TypeOfObject, dataContractName, dataContractNamespace); xmlReader.ReadEndElement(); node.IsFinalValue = false; return(node); } } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateUnexpectedStateException(XmlNodeType.Element, xmlReader)); }
private IDataNode ReadExtensionDataValue(XmlReaderDelegator xmlReader, string?dataContractName, string?dataContractNamespace) { Debug.Assert(attributes != null); StartReadExtensionDataValue(xmlReader); if (attributes.UnrecognizedAttributesFound) { return(ReadUnknownXmlData(xmlReader, dataContractName, dataContractNamespace)); } IDictionary <string, string>?namespacesInScope = xmlReader.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml); Read(xmlReader); xmlReader.MoveToContent(); switch (xmlReader.NodeType) { case XmlNodeType.Text: return(ReadPrimitiveExtensionDataValue(xmlReader, dataContractName, dataContractNamespace)); case XmlNodeType.Element: if (xmlReader.NamespaceURI.StartsWith(Globals.DataContractXsdBaseNamespace, StringComparison.Ordinal)) { return(ReadUnknownClassData(xmlReader, dataContractName, dataContractNamespace)); } else { return(ReadAndResolveUnknownXmlData(xmlReader, namespacesInScope, dataContractName, dataContractNamespace)); } case XmlNodeType.EndElement: { // NOTE: cannot distinguish between empty class or IXmlSerializable and typeof(object) IDataNode objNode = ReadUnknownPrimitiveData(xmlReader, Globals.TypeOfObject, dataContractName, dataContractNamespace); xmlReader.ReadEndElement(); objNode.IsFinalValue = false; return(objNode); } default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateUnexpectedStateException(XmlNodeType.Element, xmlReader)); } }