Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. 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; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CreateUserWizard.cs
- TabletCollection.cs
- CheckPair.cs
- InputScopeNameConverter.cs
- WindowsNonControl.cs
- TraceSection.cs
- OdbcConnectionPoolProviderInfo.cs
- SqlUtils.cs
- IsolatedStoragePermission.cs
- ArraySortHelper.cs
- XmlDataSource.cs
- Style.cs
- SwitchAttribute.cs
- ClaimComparer.cs
- ServiceHttpHandlerFactory.cs
- DecodeHelper.cs
- StreamWithDictionary.cs
- StickyNoteAnnotations.cs
- InternalPolicyElement.cs
- TableLayoutRowStyleCollection.cs
- WebBrowserProgressChangedEventHandler.cs
- ParameterCollectionEditor.cs
- CodeTypeReference.cs
- DiagnosticTrace.cs
- EpmContentSerializer.cs
- XmlILStorageConverter.cs
- ZipPackagePart.cs
- BitmapEffectRenderDataResource.cs
- _ShellExpression.cs
- BitmapInitialize.cs
- StreamGeometryContext.cs
- BasicViewGenerator.cs
- SchemaName.cs
- ProviderConnectionPoint.cs
- GrammarBuilderBase.cs
- CryptoApi.cs
- ContractInstanceProvider.cs
- TextTabProperties.cs
- ColorContext.cs
- StrongNameMembershipCondition.cs
- CodeDomConfigurationHandler.cs
- XmlSignatureManifest.cs
- RelatedImageListAttribute.cs
- ToolStripContainer.cs
- DataGridItemAutomationPeer.cs
- PtsHost.cs
- __ConsoleStream.cs
- NameHandler.cs
- UserInitiatedRoutedEventPermissionAttribute.cs
- WebPartDescription.cs
- ThaiBuddhistCalendar.cs
- IdentityManager.cs
- VoiceInfo.cs
- TraceHandler.cs
- RijndaelManaged.cs
- ModelToObjectValueConverter.cs
- httpserverutility.cs
- ClientUtils.cs
- DataGridViewToolTip.cs
- LazyInitializer.cs
- TextContainer.cs
- ScaleTransform3D.cs
- SerialReceived.cs
- ComboBoxItem.cs
- OutputChannelBinder.cs
- BackgroundFormatInfo.cs
- DataListItem.cs
- MembershipPasswordException.cs
- LinearGradientBrush.cs
- Debug.cs
- SqlDataSourceRefreshSchemaForm.cs
- PersonalizableTypeEntry.cs
- WebConfigurationManager.cs
- ComponentCommands.cs
- AutomationPeer.cs
- InheritedPropertyChangedEventArgs.cs
- ListDesigner.cs
- PointValueSerializer.cs
- CheckBoxAutomationPeer.cs
- GridItemCollection.cs
- OrderedParallelQuery.cs
- ListDataHelper.cs
- HtmlButton.cs
- WebPartMinimizeVerb.cs
- PictureBoxDesigner.cs
- WindowsNonControl.cs
- HashCryptoHandle.cs
- Inflater.cs
- CharacterString.cs
- _ProxyChain.cs
- DataMisalignedException.cs
- SspiSafeHandles.cs
- AuthorizationRuleCollection.cs
- StyleTypedPropertyAttribute.cs
- TemplatePagerField.cs
- ZipIOLocalFileHeader.cs
- HttpRuntime.cs
- DeleteBookmarkScope.cs
- RefreshEventArgs.cs
- WebMessageFormatHelper.cs