Beispiel #1
0
        public object ReadTypedValue()
        {
            if (dtdReader == null)
            {
                return(null);
            }
            XmlSchemaDatatype dt = schemaInfo.SchemaType as XmlSchemaDatatype;

            if (dt == null)
            {
                XmlSchemaType st = schemaInfo.SchemaType as XmlSchemaType;
                if (st != null)
                {
                    dt = st.Datatype;
                }
            }
            if (dt == null)
            {
                return(null);
            }
            switch (NodeType)
            {
            case XmlNodeType.Element:
                if (IsEmptyElement)
                {
                    return(null);
                }

                storedCharacters.Length = 0;
                bool loop = true;
                do
                {
                    Read();
                    switch (NodeType)
                    {
                    case XmlNodeType.Whitespace:
                    case XmlNodeType.SignificantWhitespace:
                    case XmlNodeType.Text:
                    case XmlNodeType.CDATA:
                        storedCharacters.Append(Value);
                        break;

                    case XmlNodeType.Comment:
                        break;

                    default:
                        loop = false;
                        break;
                    }
                } while (loop && !EOF);
                return(dt.ParseValue(storedCharacters.ToString(), NameTable, dtdReader.ParserContext.NamespaceManager));

            case XmlNodeType.Attribute:
                return(dt.ParseValue(Value, NameTable, dtdReader.ParserContext.NamespaceManager));
            }
            return(null);
        }
Beispiel #2
0
        /// <summary>Gets the common language runtime type for the specified XML Schema definition language (XSD) type.</summary>
        /// <returns>The common language runtime type for the specified XML Schema type.</returns>
        public object ReadTypedValue()
        {
            if (this.dtdReader == null)
            {
                return(null);
            }
            XmlSchemaDatatype xmlSchemaDatatype = this.schemaInfo.SchemaType as XmlSchemaDatatype;

            if (xmlSchemaDatatype == null)
            {
                XmlSchemaType xmlSchemaType = this.schemaInfo.SchemaType as XmlSchemaType;
                if (xmlSchemaType != null)
                {
                    xmlSchemaDatatype = xmlSchemaType.Datatype;
                }
            }
            if (xmlSchemaDatatype == null)
            {
                return(null);
            }
            XmlNodeType nodeType = this.NodeType;

            if (nodeType != XmlNodeType.Element)
            {
                if (nodeType != XmlNodeType.Attribute)
                {
                    return(null);
                }
                return(xmlSchemaDatatype.ParseValue(this.Value, this.NameTable, this.dtdReader.ParserContext.NamespaceManager));
            }
            else
            {
                if (this.IsEmptyElement)
                {
                    return(null);
                }
                this.storedCharacters.Length = 0;
                bool flag = true;
                for (;;)
                {
                    this.Read();
                    XmlNodeType nodeType2 = this.NodeType;
                    switch (nodeType2)
                    {
                    case XmlNodeType.Text:
                    case XmlNodeType.CDATA:
                        goto IL_C6;

                    default:
                        if (nodeType2 == XmlNodeType.Whitespace || nodeType2 == XmlNodeType.SignificantWhitespace)
                        {
                            goto IL_C6;
                        }
                        flag = false;
                        break;

                    case XmlNodeType.Comment:
                        break;
                    }
IL_E9:
                    if (!flag || this.EOF)
                    {
                        break;
                    }
                    continue;
IL_C6:
                    this.storedCharacters.Append(this.Value);
                    goto IL_E9;
                }
                return(xmlSchemaDatatype.ParseValue(this.storedCharacters.ToString(), this.NameTable, this.dtdReader.ParserContext.NamespaceManager));
            }
        }