in src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlValueConverter.cs [2779:2875]
public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver)
{
if (value == null) throw new ArgumentNullException("value");
if (destinationType == null) throw new ArgumentNullException("destinationType");
Type sourceType = value.GetType();
if (destinationType == ObjectType) destinationType = DefaultClrType;
if (destinationType == BooleanType)
{
if (sourceType == StringType) return XmlConvert.ToBoolean((string)value);
}
if (destinationType == ByteType)
{
if (sourceType == StringType) return Int32ToByte(XmlConvert.ToInt32((string)value));
}
if (destinationType == ByteArrayType)
{
if (sourceType == StringType) return StringToBase64Binary((string)value);
}
if (destinationType == DateTimeType)
{
if (sourceType == StringType) return UntypedAtomicToDateTime((string)value);
}
if (destinationType == DateTimeOffsetType)
{
if (sourceType == StringType) return UntypedAtomicToDateTimeOffset((string)value);
}
if (destinationType == DecimalType)
{
if (sourceType == StringType) return XmlConvert.ToDecimal((string)value);
}
if (destinationType == DoubleType)
{
if (sourceType == StringType) return XmlConvert.ToDouble((string)value);
}
if (destinationType == Int16Type)
{
if (sourceType == StringType) return Int32ToInt16(XmlConvert.ToInt32((string)value));
}
if (destinationType == Int32Type)
{
if (sourceType == StringType) return XmlConvert.ToInt32((string)value);
}
if (destinationType == Int64Type)
{
if (sourceType == StringType) return XmlConvert.ToInt64((string)value);
}
if (destinationType == SByteType)
{
if (sourceType == StringType) return Int32ToSByte(XmlConvert.ToInt32((string)value));
}
if (destinationType == SingleType)
{
if (sourceType == StringType) return XmlConvert.ToSingle((string)value);
}
if (destinationType == TimeSpanType)
{
if (sourceType == StringType) return StringToDuration((string)value);
}
if (destinationType == UInt16Type)
{
if (sourceType == StringType) return Int32ToUInt16(XmlConvert.ToInt32((string)value));
}
if (destinationType == UInt32Type)
{
if (sourceType == StringType) return Int64ToUInt32(XmlConvert.ToInt64((string)value));
}
if (destinationType == UInt64Type)
{
if (sourceType == StringType) return DecimalToUInt64(XmlConvert.ToDecimal((string)value));
}
if (destinationType == UriType)
{
if (sourceType == StringType) return XmlConvert.ToUri((string)value);
}
if (destinationType == XmlAtomicValueType)
{
if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value));
if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value);
}
if (destinationType == XmlQualifiedNameType)
{
if (sourceType == StringType) return StringToQName((string)value, nsResolver);
}
if (destinationType == XPathItemType)
{
if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value));
if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value);
}
if (destinationType == StringType) return this.ToString(value, nsResolver);
if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, this.ToString(value, nsResolver)));
if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, this.ToString(value, nsResolver)));
if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAs(destinationType, nsResolver);
return ChangeListType(value, destinationType, nsResolver);
}