title: how to deserialize GZipStream?
body: <p>I am serializing a stream and it is being stored in cloud using REST services.
  Serialization part is given below-</p>
  
  <pre><code>public void serialize(Object obj, Stream str)
      {
          using (GZipStream zipStream = new GZipStream(str, CompressionMode.Compress, true))
          {
              if (obj is Stream)//This is executed in my case
              {
                  ((Stream)obj).CopyTo(zipStream);
              }
              else
              {
                  binarySerializer.serialize(obj, zipStream);
              }
          }
      }
  </code></pre>
  
  <p>Argument <strong>obj</strong> is the stream content and <strong>str</strong> is an empty stream which stores serialized stream for further use. If condition is executed in my case since <strong>obj</strong> is a Stream.</p>
  
  <p>here is the <strong>binarySerializer.Serialize()</strong> code -</p>
  
  <pre><code>public void serialize(object obj, Stream str)
      {
          if (obj is Stream)
          {
              ((Stream)obj).CopyTo(str);
          }
          else
          {
              BinaryFormatter formatter = new BinaryFormatter();
              formatter.Serialize(str, obj);
          }
      }
  </code></pre>
  
  <p>This works fine and I am able to download the serialized file(which is displayed as binary file with download option) from cloud using <strong>Restlet Client</strong> chrome extension.</p>
  
  <p>Can anyone help me in writing the <strong>Deserialization</strong> part?
  I want the deserialization code with below signature -</p>
  
  <pre><code>public T deserialize&lt;T&gt;(Stream str)
      {
        //Code here
      }
  </code></pre>
  
  <p>Thanks in Advance!</p>