コード例 #1
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));
            }
        }