System.Xml.XsdValidatingReader.InternalReadElementContentAsObject C# (CSharp) Method

InternalReadElementContentAsObject() private method

private InternalReadElementContentAsObject ( XmlSchemaType &xmlType, bool unwrapTypedValue, string &originalString ) : object
xmlType System.Xml.Schema.XmlSchemaType
unwrapTypedValue bool
originalString string
return object
        private object InternalReadElementContentAsObject(out XmlSchemaType xmlType, bool unwrapTypedValue, out string originalString)
        {
            Debug.Assert(this.NodeType == XmlNodeType.Element);
            object typedValue = null;
            xmlType = null;
            //If its an empty element, can have default/fixed value
            if (this.IsEmptyElement)
            {
                if (_xmlSchemaInfo.ContentType == XmlSchemaContentType.TextOnly)
                {
                    typedValue = ReturnBoxedValue(_atomicValue, _xmlSchemaInfo.XmlType, unwrapTypedValue);
                }
                else
                {
                    typedValue = _atomicValue;
                }
                originalString = _originalAtomicValueString;
                xmlType = ElementXmlType; //Set this for default values 
                this.Read();

                return typedValue;
            }
            // move to content and read typed value
            this.Read();

            if (this.NodeType == XmlNodeType.EndElement)
            { //If IsDefault is true, the next node will be EndElement
                if (_xmlSchemaInfo.IsDefault)
                {
                    if (_xmlSchemaInfo.ContentType == XmlSchemaContentType.TextOnly)
                    {
                        typedValue = ReturnBoxedValue(_atomicValue, _xmlSchemaInfo.XmlType, unwrapTypedValue);
                    }
                    else
                    { //anyType has default value
                        typedValue = _atomicValue;
                    }
                    originalString = _originalAtomicValueString;
                }
                else
                { //Empty content
                    typedValue = string.Empty;
                    originalString = string.Empty;
                }
            }
            else if (this.NodeType == XmlNodeType.Element)
            { //the first child is again element node
                throw new XmlException(SR.Xml_MixedReadElementContentAs, string.Empty, this as IXmlLineInfo);
            }
            else
            {
                typedValue = InternalReadContentAsObject(unwrapTypedValue, out originalString);

                // ReadElementContentAsXXX cannot be called on mixed content, if positioned on node other than EndElement, Error
                if (this.NodeType != XmlNodeType.EndElement)
                {
                    throw new XmlException(SR.Xml_MixedReadElementContentAs, string.Empty, this as IXmlLineInfo);
                }
            }
            xmlType = ElementXmlType; //Set this as we are moving ahead to the next node

            // move to next node
            this.Read();

            return typedValue;
        }

Same methods

XsdValidatingReader::InternalReadElementContentAsObject ( XmlSchemaType &xmlType ) : object
XsdValidatingReader::InternalReadElementContentAsObject ( XmlSchemaType &xmlType, bool unwrapTypedValue ) : object
XsdValidatingReader