Exemple #1
0
        private ISerializableDataNode ReadUnknownISerializableData(XmlReaderDelegator xmlReader, string dataContractName, string dataContractNamespace)
        {
            XmlNodeType           type;
            ISerializableDataNode dataNode = new ISerializableDataNode();

            this.InitializeExtensionDataNode(dataNode, dataContractName, dataContractNamespace);
            dataNode.FactoryTypeName      = this.attributes.FactoryTypeName;
            dataNode.FactoryTypeNamespace = this.attributes.FactoryTypeNamespace;
            while ((type = xmlReader.MoveToContent()) != XmlNodeType.EndElement)
            {
                if (type != XmlNodeType.Element)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateUnexpectedStateException(XmlNodeType.Element, xmlReader));
                }
                if (xmlReader.NamespaceURI.Length != 0)
                {
                    this.SkipUnknownElement(xmlReader);
                }
                else
                {
                    ISerializableDataMember item = new ISerializableDataMember {
                        Name  = xmlReader.LocalName,
                        Value = this.ReadExtensionDataValue(xmlReader)
                    };
                    if (dataNode.Members == null)
                    {
                        dataNode.Members = new List <ISerializableDataMember>();
                    }
                    dataNode.Members.Add(item);
                }
            }
            xmlReader.ReadEndElement();
            return(dataNode);
        }
        private ISerializableDataNode ReadUnknownISerializableData(XmlReaderDelegator xmlReader, string?dataContractName, string?dataContractNamespace)
        {
            Debug.Assert(attributes != null);

            var dataNode = new ISerializableDataNode();

            InitializeExtensionDataNode(dataNode, dataContractName, dataContractNamespace);

            dataNode.FactoryTypeName      = attributes.FactoryTypeName;
            dataNode.FactoryTypeNamespace = attributes.FactoryTypeNamespace;

            XmlNodeType nodeType;

            while ((nodeType = xmlReader.MoveToContent()) != XmlNodeType.EndElement)
            {
                if (nodeType != XmlNodeType.Element)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateUnexpectedStateException(XmlNodeType.Element, xmlReader));
                }

                if (xmlReader.NamespaceURI.Length != 0)
                {
                    SkipUnknownElement(xmlReader);
                    continue;
                }

                var member = new ISerializableDataMember(xmlReader.LocalName);
                member.Value = ReadExtensionDataValue(xmlReader);
                dataNode.Members ??= new List <ISerializableDataMember>();
                dataNode.Members.Add(member);
            }
            xmlReader.ReadEndElement();
            return(dataNode);
        }
 private void MoveNextInISerializable(ISerializableDataNode dataNode)
 {
     if ((dataNode.Members != null) && (this.element.childElementIndex < dataNode.Members.Count))
     {
         if (this.element.childElementIndex == 0)
         {
             this.context.IncrementItemCount(-dataNode.Members.Count);
         }
         ISerializableDataMember member = dataNode.Members[this.element.childElementIndex++];
         this.SetNextElement(member.Value, member.Name, string.Empty, string.Empty);
     }
     else
     {
         this.internalNodeType          = ExtensionDataNodeType.EndElement;
         this.element.childElementIndex = 0;
     }
 }
Exemple #4
0
        private void MoveNextInISerializable(ISerializableDataNode dataNode)
        {
            if (dataNode.Members != null && _element.childElementIndex < dataNode.Members.Count)
            {
                if (_element.childElementIndex == 0)
                {
                    _context.IncrementItemCount(-dataNode.Members.Count);
                }

                ISerializableDataMember member = dataNode.Members[_element.childElementIndex++];
                SetNextElement(member.Value, member.Name, String.Empty, String.Empty);
            }
            else
            {
                _internalNodeType          = ExtensionDataNodeType.EndElement;
                _element.childElementIndex = 0;
            }
        }
 private void WriteExtensionISerializableData(XmlWriterDelegator xmlWriter, ISerializableDataNode dataNode)
 {
     if (!this.TryWriteDeserializedExtensionData(xmlWriter, dataNode))
     {
         this.WriteExtensionDataTypeInfo(xmlWriter, dataNode);
         if (dataNode.FactoryTypeName != null)
         {
             xmlWriter.WriteAttributeQualifiedName("z", DictionaryGlobals.ISerializableFactoryTypeLocalName, DictionaryGlobals.SerializationNamespace, dataNode.FactoryTypeName, dataNode.FactoryTypeNamespace);
         }
         IList <ISerializableDataMember> members = dataNode.Members;
         if (members != null)
         {
             for (int i = 0; i < members.Count; i++)
             {
                 ISerializableDataMember member = members[i];
                 xmlWriter.WriteStartElement(member.Name, string.Empty);
                 this.WriteExtensionDataValue(xmlWriter, member.Value);
                 xmlWriter.WriteEndElement();
             }
         }
     }
 }