private object InternalReadContentAsObject(bool unwrapTypedValue, out string originalStringValue)
{
XmlNodeType nodeType = this.NodeType;
if (nodeType == XmlNodeType.Attribute)
{
originalStringValue = this.Value;
if (_attributePSVI != null && _attributePSVI.typedAttributeValue != null)
{
if (_validationState == ValidatingReaderState.OnDefaultAttribute)
{
XmlSchemaAttribute schemaAttr = _attributePSVI.attributeSchemaInfo.SchemaAttribute;
originalStringValue = (schemaAttr.DefaultValue != null) ? schemaAttr.DefaultValue : schemaAttr.FixedValue;
}
return ReturnBoxedValue(_attributePSVI.typedAttributeValue, AttributeSchemaInfo.XmlType, unwrapTypedValue);
}
else
{ //return string value
return this.Value;
}
}
else if (nodeType == XmlNodeType.EndElement)
{
if (_atomicValue != null)
{
originalStringValue = _originalAtomicValueString;
return _atomicValue;
}
else
{
originalStringValue = string.Empty;
return string.Empty;
}
}
else
{ //Positioned on text, CDATA, PI, Comment etc
if (_validator.CurrentContentType == XmlSchemaContentType.TextOnly)
{ //if current element is of simple type
object value = ReturnBoxedValue(ReadTillEndElement(), _xmlSchemaInfo.XmlType, unwrapTypedValue);
originalStringValue = _originalAtomicValueString;
return value;
}
else
{
XsdCachingReader cachingReader = _coreReader as XsdCachingReader;
if (cachingReader != null)
{
originalStringValue = cachingReader.ReadOriginalContentAsString();
}
else
{
originalStringValue = InternalReadContentAsString();
}
return originalStringValue;
}
}
}