internal override Exception TryParseValue(object value, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue)
{
Exception exception;
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
typedValue = null;
string s = value as string;
if (s != null)
{
return TryParseValue(s, nameTable, nsmgr, out typedValue);
}
object valueToCheck = null;
XmlSchemaSimpleType memberType = null;
for (int i = 0; i < _types.Length; ++i)
{
if (_types[i].Datatype.TryParseValue(value, nameTable, nsmgr, out valueToCheck) == null)
{ //no error
memberType = _types[i];
break;
}
}
if (valueToCheck == null)
{
exception = new XmlSchemaException(SR.Sch_UnionFailedEx, value.ToString());
goto Error;
}
try
{
if (this.HasLexicalFacets)
{
string s1 = (string)this.ValueConverter.ChangeType(valueToCheck, typeof(System.String), nsmgr); //Using value here to avoid info loss
exception = unionFacetsChecker.CheckLexicalFacets(ref s1, this);
if (exception != null) goto Error;
}
typedValue = new XsdSimpleValue(memberType, valueToCheck);
if (this.HasValueFacets)
{
exception = unionFacetsChecker.CheckValueFacets(typedValue, this);
if (exception != null) goto Error;
}
return null;
}
catch (FormatException e)
{ //Catching for exceptions thrown by ValueConverter
exception = e;
}
catch (InvalidCastException e)
{ //Catching for exceptions thrown by ValueConverter
exception = e;
}
catch (OverflowException e)
{ //Catching for exceptions thrown by ValueConverter
exception = e;
}
catch (ArgumentException e)
{ //Catching for exceptions thrown by ValueConverter
exception = e;
}
Error:
return exception;
}
}