in src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/XmlBinaryReader.cs [1159:1252]
public override DateTime ReadContentAsDateTime()
{
int origPos = _pos;
DateTime value;
try
{
if (SetupContentAsXXX("ReadContentAsDateTime"))
{
try
{
switch (_token)
{
case BinXmlToken.SQL_DATETIME:
case BinXmlToken.SQL_SMALLDATETIME:
case BinXmlToken.XSD_TIME:
case BinXmlToken.XSD_DATETIME:
case BinXmlToken.XSD_DATE:
case BinXmlToken.XSD_KATMAI_DATE:
case BinXmlToken.XSD_KATMAI_DATETIME:
case BinXmlToken.XSD_KATMAI_TIME:
case BinXmlToken.XSD_KATMAI_DATEOFFSET:
case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET:
case BinXmlToken.XSD_KATMAI_TIMEOFFSET:
value = ValueAsDateTime();
break;
case BinXmlToken.SQL_BIT:
case BinXmlToken.SQL_TINYINT:
case BinXmlToken.SQL_SMALLINT:
case BinXmlToken.SQL_INT:
case BinXmlToken.SQL_BIGINT:
case BinXmlToken.SQL_REAL:
case BinXmlToken.SQL_FLOAT:
case BinXmlToken.SQL_MONEY:
case BinXmlToken.SQL_SMALLMONEY:
case BinXmlToken.SQL_DECIMAL:
case BinXmlToken.SQL_NUMERIC:
case BinXmlToken.XSD_DECIMAL:
case BinXmlToken.SQL_UUID:
case BinXmlToken.SQL_VARBINARY:
case BinXmlToken.SQL_BINARY:
case BinXmlToken.SQL_IMAGE:
case BinXmlToken.SQL_UDT:
case BinXmlToken.XSD_BINHEX:
case BinXmlToken.XSD_BASE64:
case BinXmlToken.XSD_BOOLEAN:
case BinXmlToken.XSD_BYTE:
case BinXmlToken.XSD_UNSIGNEDSHORT:
case BinXmlToken.XSD_UNSIGNEDINT:
case BinXmlToken.XSD_UNSIGNEDLONG:
case BinXmlToken.XSD_QNAME:
throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "DateTime"));
case BinXmlToken.SQL_CHAR:
case BinXmlToken.SQL_VARCHAR:
case BinXmlToken.SQL_TEXT:
case BinXmlToken.SQL_NCHAR:
case BinXmlToken.SQL_NVARCHAR:
case BinXmlToken.SQL_NTEXT:
goto Fallback;
case BinXmlToken.Element:
case BinXmlToken.EndElem:
return XmlConvert.ToDateTime(String.Empty, XmlDateTimeSerializationMode.RoundtripKind);
default:
Debug.Fail("should never happen");
goto Fallback;
}
}
catch (InvalidCastException e)
{
throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, null);
}
catch (FormatException e)
{
throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, null);
}
catch (OverflowException e)
{
throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, null);
}
origPos = FinishContentAsXXX(origPos);
return value;
}
}
finally
{
_pos = origPos;
}
Fallback:
return base.ReadContentAsDateTime();
}