System.Xml.XmlValidatingReaderImpl.ReadTypedValue C# (CSharp) Method

ReadTypedValue() public method

public ReadTypedValue ( ) : object
return object
        public object ReadTypedValue()
        {
            if (_validationType == ValidationType.None)
            {
                return null;
            }

            switch (_outerReader.NodeType)
            {
                case XmlNodeType.Attribute:
                    return _coreReaderImpl.InternalTypedValue;
                case XmlNodeType.Element:
                    if (SchemaType == null)
                    {
                        return null;
                    }
                    XmlSchemaDatatype dtype = (SchemaType is XmlSchemaDatatype) ? (XmlSchemaDatatype)SchemaType : ((XmlSchemaType)SchemaType).Datatype;
                    if (dtype != null)
                    {
                        if (!_outerReader.IsEmptyElement)
                        {
                            for (;;)
                            {
                                if (!_outerReader.Read())
                                {
                                    throw new InvalidOperationException(SR.Xml_InvalidOperation);
                                }
                                XmlNodeType type = _outerReader.NodeType;
                                if (type != XmlNodeType.CDATA && type != XmlNodeType.Text &&
                                    type != XmlNodeType.Whitespace && type != XmlNodeType.SignificantWhitespace &&
                                    type != XmlNodeType.Comment && type != XmlNodeType.ProcessingInstruction)
                                {
                                    break;
                                }
                            }
                            if (_outerReader.NodeType != XmlNodeType.EndElement)
                            {
                                throw new XmlException(SR.Xml_InvalidNodeType, _outerReader.NodeType.ToString());
                            }
                        }
                        return _coreReaderImpl.InternalTypedValue;
                    }
                    return null;

                case XmlNodeType.EndElement:
                    return null;

                default:
                    if (_coreReaderImpl.V1Compat)
                    { //If v1 XmlValidatingReader return null
                        return null;
                    }
                    else
                    {
                        return Value;
                    }
            }
        }

Usage Example

Esempio n. 1
0
 public object?ReadTypedValue()
 {
     return(_impl.ReadTypedValue());
 }