private static bool TryParseExceptionMessage(AmazonServiceException ase, out DateTime serverTime)
{
if (ase != null && !string.IsNullOrEmpty(ase.Message))
{
var message = ase.Message;
// parse server time from exception message, if possible
var parenIndex = message.IndexOf(clockSkewMessageParen, StringComparison.Ordinal);
if (parenIndex >= 0)
{
parenIndex++;
// Locate " + " or " - " separator that follows the server time string
var separatorIndex = message.IndexOf(clockSkewMessagePlusSeparator, parenIndex, StringComparison.Ordinal);
if (separatorIndex < 0)
separatorIndex = message.IndexOf(clockSkewMessageMinusSeparator, parenIndex, StringComparison.Ordinal);
// Get the server time string and parse it
if (separatorIndex > parenIndex)
{
var timestamp = message.Substring(parenIndex, separatorIndex - parenIndex);
if (DateTime.TryParseExact(
timestamp,
AWSSDKUtils.ISO8601BasicDateTimeFormat,
CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal,
out serverTime))
{
return true;
}
}
}
}
serverTime = DateTime.MinValue;
return false;
}
private static IWebResponseData GetWebData(AmazonServiceException ase)