private IServiceResponse ParseResponse(BufferCollection chunksToProcess)
{
BinaryDecoder decoder = new BinaryDecoder(new ArraySegmentStream(chunksToProcess), Quotas.MessageContext);
try
{
IServiceResponse response = BinaryDecoder.DecodeMessage(new ArraySegmentStream(chunksToProcess), null, Quotas.MessageContext) as IServiceResponse;
if (response == null)
{
throw ServiceResultException.Create(StatusCodes.BadStructureMissing, "Could not parse response body.");
}
return response;
}
finally
{
decoder.Close();
}
}