/// <summary> /// Traverse the input stream and inflate tokens that server sends to the client /// </summary> private void _InflateServerTokens(TDSClientState clientState) { // Check if we have a data stream if (_dataStream == null) { // Nothing to inflate return; } // Position to the beginning on the stream _dataStream.Seek(0, SeekOrigin.Begin); // Check client state switch (clientState) { case TDSClientState.PreLoginSent: { // Create a pre-login token Add(new TDSPreLoginToken(_dataStream)); break; } default: { // Check message type switch (MessageType) { case TDSMessageType.Response: { // Server responses must be inflated using token factory AddRange(TDSTokenFactory.Create(_dataStream)); break; } default: { // We don't recognize this message type throw new NotImplementedException(string.Format("Inflation for {0} TDS message is not implemented", MessageType)); } } break; } } // Inflation is complete so we should release the stream _dataStream.Dispose(); // Make sure we're not going to reuse it _dataStream = null; }
/// <summary> /// Inflate the message from protocol-aware stream on the client side /// </summary> /// <param name="clientState">State of the client parser</param> /// <param name="stream">Source to inflate the message</param> public bool InflateServerResponse(TDSClientState clientState, TDSStream stream) { // Chck if data stream is fully inflated if (!_InflateDataStream(stream)) { return(false); } // Inflate all tokens in the stream _InflateServerTokens(clientState); // If we reached this point it means that both data and tokens are inflated return(true); }