本文整理汇总了C#中GZipStream.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# GZipStream.Flush方法的具体用法?C# GZipStream.Flush怎么用?C# GZipStream.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GZipStream
的用法示例。
在下文中一共展示了GZipStream.Flush方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FlushFailsAfterDispose
public void FlushFailsAfterDispose()
{
var ms = new MemoryStream();
var ds = new GZipStream(ms, CompressionMode.Compress);
ds.Dispose();
Assert.Throws<ObjectDisposedException>(() => { ds.Flush(); });
}
示例2: Flush
public async Task Flush()
{
var ms = new MemoryStream();
var ds = new GZipStream(ms, CompressionMode.Compress);
ds.Flush();
await ds.FlushAsync();
// Just ensuring Flush doesn't throw
}
示例3: SerializeCompressedJson
/// <summary>
/// Serializes an IBatch to a JSON and compresses it
/// </summary>
/// <param name="batch">The IBatch to serialize</param>
/// <param name="stream">The stream to write the serialized data to</param>
internal static void SerializeCompressedJson(this IBatch batch, Stream stream)
{
using (var gzipStream = new GZipStream(stream, CompressionMode.Compress, true))
{
TextWriter textWriter = new StreamWriter(gzipStream);
textWriter.Write(batch.SerializeToJson());
textWriter.Flush();
gzipStream.Flush();
}
}
示例4: TestNotSupported
public void TestNotSupported()
{
Stream baseStream = new MemoryStream(this.compressedData);
GZipStream gzipStream = new GZipStream(baseStream, CompressionMode.Decompress);
try { gzipStream.Write(null, 0, 0); }
catch (NotSupportedException) {}
try { gzipStream.Flush(); }
catch (NotSupportedException) {}
try { gzipStream.Seek(0, SeekOrigin.Begin); }
catch (NotSupportedException) {}
try { gzipStream.SetLength(0); }
catch (NotSupportedException) {}
}
示例5: SerializeCompressedXml
/// <summary>
/// Serializes an IBatch to a XML and compresses it
/// </summary>
/// <param name="batch">The IBatch to serialize</param>
/// <param name="stream">The stream to write the serialized and compressed data to</param>
internal static void SerializeCompressedXml(this IBatch batch, Stream stream)
{
using (var gzipStream = new GZipStream(stream, CompressionMode.Compress, true))
{
batch.SerializeUncompressedXml(gzipStream);
gzipStream.Flush();
}
}