Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- TemplateBindingExpression.cs
- DirtyTextRange.cs
- NullRuntimeConfig.cs
- AppDomainManager.cs
- BindingExpressionUncommonField.cs
- CharacterShapingProperties.cs
- OracleBoolean.cs
- MetabaseSettings.cs
- ToolTipService.cs
- TextProperties.cs
- XmlSchemaComplexContentRestriction.cs
- SafeRightsManagementPubHandle.cs
- VisualTreeHelper.cs
- ObjectDataSourceSelectingEventArgs.cs
- SerialPinChanges.cs
- DataGrid.cs
- PartitionedDataSource.cs
- IPEndPoint.cs
- ButtonFieldBase.cs
- ImageList.cs
- WindowsTab.cs
- EntityDataSourceContextDisposingEventArgs.cs
- DesignOnlyAttribute.cs
- DataReceivedEventArgs.cs
- ObjectQuery.cs
- HMACSHA1.cs
- KerberosRequestorSecurityToken.cs
- ProcessThreadCollection.cs
- ScrollData.cs
- SEHException.cs
- MetafileHeader.cs
- DecoderReplacementFallback.cs
- AssemblyInfo.cs
- PrincipalPermission.cs
- Floater.cs
- WebRequestModuleElementCollection.cs
- BitmapEffectvisualstate.cs
- MessageSecurityOverHttpElement.cs
- Constraint.cs
- WizardPanel.cs
- CollectionCodeDomSerializer.cs
- ScriptModule.cs
- AdjustableArrowCap.cs
- EnumerableRowCollectionExtensions.cs
- HtmlElement.cs
- DataBindingExpressionBuilder.cs
- XmlCharCheckingWriter.cs
- CheckBoxAutomationPeer.cs
- CollectionType.cs
- LinkedList.cs
- ActivityCompletionCallbackWrapper.cs
- InstanceData.cs
- SmiMetaData.cs
- PasswordPropertyTextAttribute.cs
- CornerRadius.cs
- FacetValueContainer.cs
- BindingSource.cs
- SettingsAttributeDictionary.cs
- GlobalProxySelection.cs
- PropertyBuilder.cs
- GridSplitterAutomationPeer.cs
- AutoGeneratedField.cs
- FreezableCollection.cs
- XmlQueryType.cs
- UnmanagedMemoryStreamWrapper.cs
- ClassDataContract.cs
- EdmProperty.cs
- RegexWorker.cs
- BackStopAuthenticationModule.cs
- SchemaHelper.cs
- NameScopePropertyAttribute.cs
- RSAPKCS1SignatureFormatter.cs
- WebPartTransformer.cs
- AffineTransform3D.cs
- ArrayList.cs
- HtmlInputHidden.cs
- WebPartAddingEventArgs.cs
- FixedTextPointer.cs
- GridViewPageEventArgs.cs
- DockPattern.cs
- File.cs
- DataGridPreparingCellForEditEventArgs.cs
- WebPartUtil.cs
- LastQueryOperator.cs
- EditingCoordinator.cs
- SubMenuStyle.cs
- Module.cs
- CookieParameter.cs
- HitTestParameters3D.cs
- IdentityNotMappedException.cs
- SoapObjectReader.cs
- ConstrainedGroup.cs
- DataGridAddNewRow.cs
- PriorityChain.cs
- TrustDriver.cs
- SubpageParagraph.cs
- SoapReflectionImporter.cs
- ConnectionPoolManager.cs
- InternalTypeHelper.cs
- Pair.cs