object ReadTypedPrimitive(XmlQualifiedName qname, bool reportUnknown)
        {
            if (qname == null)
            {
                qname = GetXsiType();
            }

            TypeData typeData = TypeTranslator.FindPrimitiveTypeData(qname.Name);

            if (typeData == null || typeData.SchemaType != SchemaTypes.Primitive)
            {
                // Put everything into a node array
                readCount++;
                XmlNode node = Document.ReadNode(reader);

                if (reportUnknown)
                {
                    OnUnknownNode(node, null, null);
                }

                if (node.ChildNodes.Count == 0 && node.Attributes.Count == 0)
                {
                    return(new Object());
                }

                XmlElement elem = node as XmlElement;

                if (elem == null)
                {
                    return new XmlNode[] { node }
                }
                ;
                else
                {
                    XmlNode[] nodes = new XmlNode[elem.Attributes.Count + elem.ChildNodes.Count];

                    int n = 0;
                    foreach (XmlNode no in elem.Attributes)
                    {
                        nodes[n++] = no;
                    }
                    foreach (XmlNode no in elem.ChildNodes)
                    {
                        nodes[n++] = no;
                    }
                    return(nodes);
                }
            }

            if (typeData.Type == typeof(XmlQualifiedName))
            {
                return(ReadNullableQualifiedName());
            }
            readCount++;
            return(XmlCustomFormatter.FromXmlString(typeData, Reader.ReadElementString()));
        }
Beispiel #2
0
 private object GetValueFromXmlString(string value, TypeData typeData, XmlTypeMapping typeMap)
 {
     if (typeData.SchemaType == SchemaTypes.Array)
     {
         return(this.ReadListString(typeMap, value));
     }
     if (typeData.SchemaType == SchemaTypes.Enum)
     {
         return(this.GetEnumValue(typeMap, value));
     }
     if (typeData.Type == typeof(XmlQualifiedName))
     {
         return(base.ToXmlQualifiedName(value));
     }
     return(XmlCustomFormatter.FromXmlString(typeData, value));
 }