Code:
/ DotNET / DotNET / 8.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
- ByeMessage11.cs
- DBDataPermission.cs
- BaseDataListComponentEditor.cs
- StrongName.cs
- DecoderBestFitFallback.cs
- LineGeometry.cs
- ResolveNameEventArgs.cs
- Clipboard.cs
- SafeRegistryHandle.cs
- ManagedWndProcTracker.cs
- Setter.cs
- DataGridCommandEventArgs.cs
- odbcmetadatacolumnnames.cs
- XmlTextEncoder.cs
- X509CertificateStore.cs
- CompressStream.cs
- HtmlElementEventArgs.cs
- TextDocumentView.cs
- ProviderConnectionPoint.cs
- ServiceSettingsResponseInfo.cs
- SmiGettersStream.cs
- WebPartMenu.cs
- TemplateXamlTreeBuilder.cs
- RawStylusInputReport.cs
- ObjectQueryState.cs
- SecurityTokenTypes.cs
- StrokeNodeEnumerator.cs
- InfiniteTimeSpanConverter.cs
- TextDecoration.cs
- RadioButton.cs
- FormatException.cs
- PropertyValueUIItem.cs
- XDRSchema.cs
- StringUtil.cs
- InfoCardBaseException.cs
- XdrBuilder.cs
- JsonServiceDocumentSerializer.cs
- EntityWithChangeTrackerStrategy.cs
- X509Certificate2Collection.cs
- DataGridBoolColumn.cs
- SystemResourceHost.cs
- WebPartAuthorizationEventArgs.cs
- ObjectStorage.cs
- DataGridViewRowEventArgs.cs
- CompiledIdentityConstraint.cs
- TimeSpan.cs
- datacache.cs
- CodeTypeReferenceCollection.cs
- TaskSchedulerException.cs
- Atom10FormatterFactory.cs
- MiniAssembly.cs
- SuppressIldasmAttribute.cs
- ColorIndependentAnimationStorage.cs
- CompiledQuery.cs
- CodeGotoStatement.cs
- ConnectorRouter.cs
- CatalogZone.cs
- StackOverflowException.cs
- PagerStyle.cs
- Helpers.cs
- UnsafeNativeMethods.cs
- TreeNodeStyle.cs
- coordinatorfactory.cs
- CryptoKeySecurity.cs
- GreenMethods.cs
- WhitespaceRuleReader.cs
- SqlDelegatedTransaction.cs
- IpcManager.cs
- CaseStatement.cs
- AccessedThroughPropertyAttribute.cs
- InvalidCardException.cs
- SecurityTokenParameters.cs
- EventDescriptor.cs
- HtmlImage.cs
- HandlerFactoryWrapper.cs
- IISUnsafeMethods.cs
- XPathDescendantIterator.cs
- NavigateEvent.cs
- XmlAnyElementAttribute.cs
- _HeaderInfo.cs
- PropertyCollection.cs
- RegisteredExpandoAttribute.cs
- AppDomainInstanceProvider.cs
- InputReferenceExpression.cs
- KeySpline.cs
- DataGridItemAttachedStorage.cs
- DeclaredTypeValidatorAttribute.cs
- CodeIdentifier.cs
- WindowsRebar.cs
- SendAgentStatusRequest.cs
- ParameterReplacerVisitor.cs
- SqlDataAdapter.cs
- RemoteWebConfigurationHost.cs
- BufferedReadStream.cs
- FusionWrap.cs
- PropertyCondition.cs
- BookmarkNameHelper.cs
- FaultContractInfo.cs
- GuidelineSet.cs
- ClientConfigPaths.cs