Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- CryptoApi.cs
- SBCSCodePageEncoding.cs
- DataGridViewCellFormattingEventArgs.cs
- BaseComponentEditor.cs
- COM2PictureConverter.cs
- BasicKeyConstraint.cs
- BitmapEffectrendercontext.cs
- ToolStripDropDownButton.cs
- Dispatcher.cs
- TemplatedEditableDesignerRegion.cs
- WindowsFormsSynchronizationContext.cs
- TripleDESCryptoServiceProvider.cs
- DataList.cs
- Pkcs9Attribute.cs
- ModuleBuilder.cs
- DataGridColumnReorderingEventArgs.cs
- GetChildSubtree.cs
- FrameSecurityDescriptor.cs
- SchemaInfo.cs
- ResXResourceWriter.cs
- ExpressionVisitor.cs
- DataGridToolTip.cs
- PagePropertiesChangingEventArgs.cs
- XamlStyleSerializer.cs
- TextSimpleMarkerProperties.cs
- DbCommandDefinition.cs
- ValidationManager.cs
- RegexGroupCollection.cs
- BookmarkWorkItem.cs
- NegationPusher.cs
- Pair.cs
- XmlSchemaElement.cs
- BinaryObjectReader.cs
- BaseParser.cs
- SubMenuStyleCollection.cs
- LassoSelectionBehavior.cs
- VariableExpressionConverter.cs
- StandardOleMarshalObject.cs
- ResourcePermissionBase.cs
- SubclassTypeValidatorAttribute.cs
- GridViewUpdatedEventArgs.cs
- ButtonAutomationPeer.cs
- SettingsPropertyValueCollection.cs
- Stylesheet.cs
- ResolvePPIDRequest.cs
- InputProviderSite.cs
- BindingWorker.cs
- InteropTrackingRecord.cs
- DataGridViewCellPaintingEventArgs.cs
- XmlHierarchicalEnumerable.cs
- SourceFilter.cs
- BaseTemplatedMobileComponentEditor.cs
- DataGridCaption.cs
- RootCodeDomSerializer.cs
- BevelBitmapEffect.cs
- ScriptingWebServicesSectionGroup.cs
- PropertyReference.cs
- ExpressionBuilderCollection.cs
- DataTablePropertyDescriptor.cs
- WebResponse.cs
- XmlStreamNodeWriter.cs
- RC2CryptoServiceProvider.cs
- StickyNote.cs
- SmtpException.cs
- CompilerInfo.cs
- WebPartCatalogAddVerb.cs
- altserialization.cs
- ZeroOpNode.cs
- StringUtil.cs
- Pen.cs
- DataGridViewUtilities.cs
- ScalarType.cs
- ToolBarTray.cs
- XPathItem.cs
- DelegatingConfigHost.cs
- DependencyObjectPropertyDescriptor.cs
- FontUnitConverter.cs
- PathFigureCollection.cs
- GridViewColumnCollection.cs
- CodeGenerator.cs
- HttpListener.cs
- TreeNodeEventArgs.cs
- HMACSHA512.cs
- SapiAttributeParser.cs
- DebugController.cs
- ToolStripArrowRenderEventArgs.cs
- DescendantQuery.cs
- RuntimeConfig.cs
- sqlmetadatafactory.cs
- ValidationEventArgs.cs
- SparseMemoryStream.cs
- BooleanStorage.cs
- SafeNativeMethodsOther.cs
- AffineTransform3D.cs
- TextDecorations.cs
- SecurityRuntime.cs
- TreeNodeBindingCollection.cs
- RewritingProcessor.cs
- XmlWrappingReader.cs
- XmlSerializer.cs