private object ValidateAtomicValue(object parsedValue, out XmlSchemaSimpleType memberType)
{
memberType = null;
SchemaElementDecl currentElementDecl = _context.ElementDecl;
object typedValue = null;
if (!_context.IsNill)
{
SchemaDeclBase decl = currentElementDecl as SchemaDeclBase;
XmlSchemaDatatype dtype = currentElementDecl.Datatype;
Exception exception = dtype.TryParseValue(parsedValue, _nameTable, _nsResolver, out typedValue);
if (exception != null)
{
string stringValue = parsedValue as string;
if (stringValue == null)
{
stringValue = XmlSchemaDatatype.ConcatenatedToString(parsedValue);
}
SendValidationEvent(SR.Sch_ElementValueDataTypeDetailed, new string[] { QNameString(_context.LocalName, _context.Namespace), stringValue, GetTypeName(decl), exception.Message }, exception);
return null;
}
if (!decl.CheckValue(typedValue))
{
SendValidationEvent(SR.Sch_FixedElementValue, QNameString(_context.LocalName, _context.Namespace));
}
if (dtype.Variety == XmlSchemaDatatypeVariety.Union)
{
XsdSimpleValue simpleValue = typedValue as XsdSimpleValue;
Debug.Assert(simpleValue != null);
memberType = simpleValue.XmlType;
typedValue = simpleValue.TypedValue;
dtype = memberType.Datatype;
}
CheckTokenizedTypes(dtype, typedValue, false);
}
return typedValue;
}