D2L.Extensibility.AuthSdk.Impl.TimestampParser.TryParseTimestamp C# (CSharp) Method

TryParseTimestamp() private method

Extracts the timestamp from a request body if the body says "Timestamp out of range"
private TryParseTimestamp ( string timestampMessage, long &result ) : bool
timestampMessage string The requestr body which may indicated the timestamp is out of range
result long The timestamp provided by the server
return bool
        internal bool TryParseTimestamp( string timestampMessage, out long result )
        {
            var regex = new Regex( "Timestamp out of range\\s*(\\d+)", RegexOptions.Multiline );
            Match match = regex.Match( timestampMessage );
            if( match.Success && match.Groups.Count >= 2 ) {
                result = Int64.Parse( match.Groups[ 1 ].Value );
                return true;
            }
            result = 0;
            return false;
        }

Usage Example

 public void TimestampParser_GivenTimestampOutOfRangeMessage_ReturnsTrue()
 {
     var parser = new TimestampParser();
     long timestamp;
     bool result = parser.TryParseTimestamp( TEST_TIMESTAMP_MESSAGE, out timestamp );
     Assert.IsTrue( result );
 }
All Usage Examples Of D2L.Extensibility.AuthSdk.Impl.TimestampParser::TryParseTimestamp
TimestampParser