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
- TextElementCollection.cs
- MultiSelector.cs
- SamlSerializer.cs
- ToolStripSettings.cs
- IdentityNotMappedException.cs
- StreamGeometry.cs
- GregorianCalendar.cs
- ModulesEntry.cs
- FileCodeGroup.cs
- FaultHandlingFilter.cs
- TextTreeTextElementNode.cs
- SoapTransportImporter.cs
- SqlDataSourceWizardForm.cs
- ExpressionBuilderCollection.cs
- SpeechSynthesizer.cs
- RightsManagementPermission.cs
- Line.cs
- WorkflowApplicationCompletedException.cs
- WebHttpSecurityElement.cs
- TdsParser.cs
- PathTooLongException.cs
- ParagraphVisual.cs
- StorageEntitySetMapping.cs
- MarshalByValueComponent.cs
- DrawingVisualDrawingContext.cs
- SafeCertificateStore.cs
- TextAdaptor.cs
- Random.cs
- WebPartTransformerAttribute.cs
- CodeSubDirectory.cs
- PersonalizationStateQuery.cs
- SqlCommand.cs
- ToolStripArrowRenderEventArgs.cs
- DelegateOutArgument.cs
- AudioBase.cs
- SchemaCollectionCompiler.cs
- SqlDataReaderSmi.cs
- SerializationAttributes.cs
- AuthenticateEventArgs.cs
- Logging.cs
- ListChangedEventArgs.cs
- TimeoutException.cs
- MemberAccessException.cs
- LinqDataSourceEditData.cs
- UnicodeEncoding.cs
- SQLInt32Storage.cs
- WeakReadOnlyCollection.cs
- BitmapEffectInput.cs
- StyleReferenceConverter.cs
- PerformanceCounterPermissionAttribute.cs
- Binding.cs
- IndexerNameAttribute.cs
- NavigationHelper.cs
- ProgressBarRenderer.cs
- SystemTcpStatistics.cs
- IndentTextWriter.cs
- MetadataAssemblyHelper.cs
- SqlClientFactory.cs
- PropertyValueUIItem.cs
- FormViewInsertEventArgs.cs
- FileChangesMonitor.cs
- DataObject.cs
- StringResourceManager.cs
- ConfigXmlAttribute.cs
- OdbcPermission.cs
- MarkupWriter.cs
- ListViewPagedDataSource.cs
- ControlOperationBehavior.cs
- SuppressIldasmAttribute.cs
- SqlDataSourceView.cs
- WebServiceClientProxyGenerator.cs
- WebPartsPersonalizationAuthorization.cs
- MethodBuilder.cs
- SystemIcmpV6Statistics.cs
- VirtualDirectoryMappingCollection.cs
- HttpApplication.cs
- VariableQuery.cs
- ReferencedCollectionType.cs
- QueryStoreStatusRequest.cs
- EnumerableRowCollectionExtensions.cs
- ExeContext.cs
- BinaryQueryOperator.cs
- ErrorWebPart.cs
- ColorTranslator.cs
- dbenumerator.cs
- EntityDataSourceUtil.cs
- VisualStyleTypesAndProperties.cs
- AssemblyFilter.cs
- SafeNativeMethods.cs
- QueryOutputWriter.cs
- ExtensionWindow.cs
- ParameterModifier.cs
- ConnectionPoint.cs
- XmlQualifiedNameTest.cs
- CellTreeNodeVisitors.cs
- FileFormatException.cs
- PropertyInformation.cs
- WmfPlaceableFileHeader.cs
- XmlSchemaAnyAttribute.cs
- PersonalizationProvider.cs