Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Sys / System / IO / compression / GZipStream.cs / 1 / GZipStream.cs
namespace System.IO.Compression {
using System.IO;
using System.Diagnostics;
using System.Security.Permissions;
public class GZipStream : Stream {
private DeflateStream deflateStream;
public GZipStream(Stream stream, CompressionMode mode) : this( stream, mode, false) {
}
public GZipStream(Stream stream, CompressionMode mode, bool leaveOpen) {
deflateStream = new DeflateStream(stream, mode, leaveOpen, true);
}
public override bool CanRead {
get {
if( deflateStream == null) {
return false;
}
return deflateStream.CanRead;
}
}
public override bool CanWrite {
get {
if( deflateStream == null) {
return false;
}
return deflateStream.CanWrite;
}
}
public override bool CanSeek {
get {
if( deflateStream == null) {
return false;
}
return deflateStream.CanSeek;
}
}
public override long Length {
get {
throw new NotSupportedException(SR.GetString(SR.NotSupported));
}
}
public override long Position {
get {
throw new NotSupportedException(SR.GetString(SR.NotSupported));
}
set {
throw new NotSupportedException(SR.GetString(SR.NotSupported));
}
}
public override void Flush() {
if( deflateStream == null) {
throw new ObjectDisposedException(null, SR.GetString(SR.ObjectDisposed_StreamClosed));
}
deflateStream.Flush();
return;
}
public override long Seek(long offset, SeekOrigin origin) {
throw new NotSupportedException(SR.GetString(SR.NotSupported));
}
public override void SetLength(long value) {
throw new NotSupportedException(SR.GetString(SR.NotSupported));
}
[HostProtection(ExternalThreading=true)]
public override IAsyncResult BeginRead(byte[] array, int offset, int count, AsyncCallback asyncCallback, object asyncState) {
if( deflateStream == null) {
throw new InvalidOperationException(SR.GetString(SR.ObjectDisposed_StreamClosed));
}
return deflateStream.BeginRead(array, offset, count, asyncCallback, asyncState);
}
public override int EndRead(IAsyncResult asyncResult) {
if( deflateStream == null) {
throw new InvalidOperationException(SR.GetString(SR.ObjectDisposed_StreamClosed));
}
return deflateStream.EndRead(asyncResult);
}
[HostProtection(ExternalThreading=true)]
public override IAsyncResult BeginWrite(byte[] array, int offset, int count, AsyncCallback asyncCallback, object asyncState) {
if( deflateStream == null) {
throw new InvalidOperationException(SR.GetString(SR.ObjectDisposed_StreamClosed));
}
return deflateStream.BeginWrite(array, offset, count, asyncCallback, asyncState);
}
public override void EndWrite(IAsyncResult asyncResult) {
if( deflateStream == null) {
throw new InvalidOperationException(SR.GetString(SR.ObjectDisposed_StreamClosed));
}
deflateStream.EndWrite(asyncResult);
}
public override int Read(byte[] array, int offset, int count) {
if( deflateStream == null) {
throw new ObjectDisposedException(null, SR.GetString(SR.ObjectDisposed_StreamClosed));
}
return deflateStream.Read(array, offset, count);
}
public override void Write(byte[] array, int offset, int count) {
if( deflateStream == null) {
throw new ObjectDisposedException(null, SR.GetString(SR.ObjectDisposed_StreamClosed));
}
deflateStream.Write(array, offset, count);
}
protected override void Dispose(bool disposing) {
try {
if (disposing && deflateStream != null) {
deflateStream.Close();
}
deflateStream = null;
}
finally {
base.Dispose(disposing);
}
}
public Stream BaseStream {
get {
if( deflateStream != null) {
return deflateStream.BaseStream;
}
else {
return null;
}
}
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- VisualBrush.cs
- DocumentSequence.cs
- InkCanvasSelectionAdorner.cs
- PrePrepareMethodAttribute.cs
- ReadOnlyDictionary.cs
- HwndAppCommandInputProvider.cs
- OdbcEnvironmentHandle.cs
- XmlNamespaceManager.cs
- ModelTypeConverter.cs
- SyndicationDeserializer.cs
- entitydatasourceentitysetnameconverter.cs
- MergeFilterQuery.cs
- RegularExpressionValidator.cs
- UpdateManifestForBrowserApplication.cs
- MDIControlStrip.cs
- SqlEnums.cs
- CodeCatchClauseCollection.cs
- RegexRunner.cs
- Invariant.cs
- DataGridView.cs
- TypeViewSchema.cs
- CngUIPolicy.cs
- _NetRes.cs
- SemanticResultKey.cs
- UpdateTracker.cs
- PropertyChangeTracker.cs
- MatrixIndependentAnimationStorage.cs
- nulltextcontainer.cs
- Documentation.cs
- CorePropertiesFilter.cs
- BitmapInitialize.cs
- ExtendedPropertyCollection.cs
- NamespaceQuery.cs
- EmbeddedObject.cs
- FunctionImportElement.cs
- RuntimeEnvironment.cs
- SqlCacheDependencyDatabase.cs
- MetaDataInfo.cs
- BaseProcessProtocolHandler.cs
- DataDocumentXPathNavigator.cs
- XamlStyleSerializer.cs
- DataGridViewSelectedRowCollection.cs
- FilePrompt.cs
- WmlTextViewAdapter.cs
- DesigntimeLicenseContextSerializer.cs
- MachineKeyConverter.cs
- DbgCompiler.cs
- XmlQualifiedName.cs
- GridToolTip.cs
- TextInfo.cs
- ConfigXmlElement.cs
- SimpleExpression.cs
- AutoGeneratedFieldProperties.cs
- MetadataItemEmitter.cs
- WebHttpEndpoint.cs
- Viewport2DVisual3D.cs
- PrimaryKeyTypeConverter.cs
- OutputWindow.cs
- MimeTextImporter.cs
- ADConnectionHelper.cs
- WebPartTransformerCollection.cs
- XamlHostingSectionGroup.cs
- entitydatasourceentitysetnameconverter.cs
- XPathItem.cs
- XmlnsDictionary.cs
- ArraySortHelper.cs
- SafeUserTokenHandle.cs
- VerificationAttribute.cs
- ReadOnlyObservableCollection.cs
- X509Utils.cs
- HtmlInputCheckBox.cs
- HijriCalendar.cs
- Color.cs
- CreateParams.cs
- FilteredSchemaElementLookUpTable.cs
- CopyNamespacesAction.cs
- Crypto.cs
- MergeFilterQuery.cs
- SAPICategories.cs
- WpfGeneratedKnownProperties.cs
- Camera.cs
- DelegateTypeInfo.cs
- SettingsAttributeDictionary.cs
- ProtocolsInstallComponent.cs
- NumberFormatInfo.cs
- AttributeCollection.cs
- ObjectViewEntityCollectionData.cs
- MetadataPropertyAttribute.cs
- ByteRangeDownloader.cs
- _NegotiateClient.cs
- CustomAttributeSerializer.cs
- StrokeCollection.cs
- HttpsTransportBindingElement.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- SafeNativeMethods.cs
- ValidationSummary.cs
- CompressedStack.cs
- UnsafeNativeMethods.cs
- MeshGeometry3D.cs
- SqlDataSourceCache.cs