private object ReturnBoxedValue(object typedValue, XmlSchemaType xmlType, bool unWrap)
{
if (typedValue != null)
{
if (unWrap)
{ //convert XmlAtomicValue[] to object[] for list of unions; The other cases return typed value of the valueType anyway
Debug.Assert(xmlType != null && xmlType.Datatype != null);
if (xmlType.Datatype.Variety == XmlSchemaDatatypeVariety.List)
{
Datatype_List listType = xmlType.Datatype as Datatype_List;
if (listType.ItemType.Variety == XmlSchemaDatatypeVariety.Union)
{
typedValue = xmlType.ValueConverter.ChangeType(typedValue, xmlType.Datatype.ValueType, _thisNSResolver);
}
}
}
return typedValue;
}
else
{ //return the original string value of the element or attribute
Debug.Assert(NodeType != XmlNodeType.Attribute);
typedValue = _validator.GetConcatenatedValue();
}
return typedValue;
}