private async Task<Tuple<XmlSchemaType, string, object>> InternalReadElementContentAsObjectTupleAsync(bool unwrapTypedValue)
{
Tuple<XmlSchemaType, string, object> tuple;
XmlSchemaType xmlType;
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
await this.ReadAsync().ConfigureAwait(false);
tuple = new Tuple<XmlSchemaType, string, object>(xmlType, originalString, typedValue);
return tuple;
}
// move to content and read typed value
await this.ReadAsync().ConfigureAwait(false);
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
{
var tuple_14 = await InternalReadContentAsObjectTupleAsync(unwrapTypedValue).ConfigureAwait(false);
originalString = tuple_14.Item1;
typedValue = tuple_14.Item2;
// 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
await this.ReadAsync().ConfigureAwait(false);
tuple = new Tuple<XmlSchemaType, string, object>(xmlType, originalString, typedValue);
return tuple;
}