internal override Exception TryParseValue(object value, XmlNameTable nameTable, IXmlNamespaceResolver namespaceResolver, out object typedValue)
{
Exception exception = null;
typedValue = null;
if (value == null)
{
return new ArgumentNullException(nameof(value));
}
string s = value as string;
if (s != null)
{
return TryParseValue(s, nameTable, namespaceResolver, out typedValue);
}
try
{
object valueToCheck = value;
if (value.GetType() != this.ValueType)
{
valueToCheck = this.ValueConverter.ChangeType(value, this.ValueType, namespaceResolver);
}
if (this.HasLexicalFacets)
{
string s1 = (string)this.ValueConverter.ChangeType(value, typeof(System.String), namespaceResolver); //Using value here to avoid info loss
exception = this.FacetsChecker.CheckLexicalFacets(ref s1, this);
if (exception != null) goto Error;
}
if (this.HasValueFacets)
{
exception = this.FacetsChecker.CheckValueFacets(valueToCheck, this);
if (exception != null) goto Error;
}
typedValue = valueToCheck;
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;
}