Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Sys / System / IO / compression / GZipStream.cs / 1305376 / 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); if (mode == CompressionMode.Compress) { IFileFormatWriter writeCommand = new GZipFormatter(); deflateStream.SetFileFormatWriter(writeCommand); } else { IFileFormatReader readCommand = new GZipDecoder(); deflateStream.SetFileFormatReader(readCommand); } } 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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CollectionBase.cs
- SoapProtocolImporter.cs
- DataGridViewTextBoxColumn.cs
- TextEditorThreadLocalStore.cs
- Unit.cs
- MsmqHostedTransportManager.cs
- IdentityManager.cs
- DeferredElementTreeState.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- AssemblySettingAttributes.cs
- AssemblyLoader.cs
- EventManager.cs
- SmiEventStream.cs
- ListView.cs
- SynchronizedDispatch.cs
- Trigger.cs
- Model3DCollection.cs
- SystemMulticastIPAddressInformation.cs
- ProxyWebPartManager.cs
- IssuedSecurityTokenParameters.cs
- NamespaceQuery.cs
- DataControlButton.cs
- TypeSystem.cs
- TdsRecordBufferSetter.cs
- EdmToObjectNamespaceMap.cs
- SiteMapProvider.cs
- ReadOnlyCollectionBuilder.cs
- FontCacheUtil.cs
- BrowserCapabilitiesFactory.cs
- KeyToListMap.cs
- GlyphRunDrawing.cs
- SubqueryRules.cs
- XamlToRtfParser.cs
- DataView.cs
- ToolStripSystemRenderer.cs
- sqlstateclientmanager.cs
- CellParaClient.cs
- ConfigurationElementCollection.cs
- AttachedPropertyBrowsableAttribute.cs
- InputLanguageEventArgs.cs
- DataTableReaderListener.cs
- PanelDesigner.cs
- SchemaImporterExtension.cs
- DispatchRuntime.cs
- ServicePerformanceCounters.cs
- sortedlist.cs
- Point3DAnimationBase.cs
- TypeHelper.cs
- AccessDataSource.cs
- wgx_sdk_version.cs
- _DisconnectOverlappedAsyncResult.cs
- WeakEventManager.cs
- _OSSOCK.cs
- HtmlMobileTextWriter.cs
- UInt32.cs
- PresentationAppDomainManager.cs
- RepeatBehavior.cs
- FixedNode.cs
- DeviceContext.cs
- DataGridViewComboBoxColumn.cs
- ObjectDataSourceWizardForm.cs
- EntityCollection.cs
- Type.cs
- GenericsNotImplementedException.cs
- ComponentChangingEvent.cs
- _LocalDataStore.cs
- CollectionViewGroupRoot.cs
- XsdDateTime.cs
- IPCCacheManager.cs
- OleDbWrapper.cs
- DecoderExceptionFallback.cs
- OdbcCommand.cs
- TextBox.cs
- ValidatedControlConverter.cs
- BitVector32.cs
- DocumentPageViewAutomationPeer.cs
- XsltConvert.cs
- PersistenceTypeAttribute.cs
- DateTimeOffset.cs
- KeyedCollection.cs
- FormsAuthenticationConfiguration.cs
- IndexedGlyphRun.cs
- VectorAnimationUsingKeyFrames.cs
- ThreadExceptionDialog.cs
- SchemaDeclBase.cs
- HeaderUtility.cs
- HostingPreferredMapPath.cs
- SQLMoney.cs
- TableAdapterManagerMethodGenerator.cs
- DeflateStream.cs
- SqlError.cs
- HelpProvider.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- RadioButtonList.cs
- ScriptingJsonSerializationSection.cs
- HttpBindingExtension.cs
- RijndaelManagedTransform.cs
- Type.cs
- DLinqDataModelProvider.cs
- ILGen.cs