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
- BaseComponentEditor.cs
- AnnotationAuthorChangedEventArgs.cs
- DbConnectionHelper.cs
- Restrictions.cs
- CommandValueSerializer.cs
- path.cs
- RegexCode.cs
- XComponentModel.cs
- XsltOutput.cs
- Events.cs
- LocalFileSettingsProvider.cs
- CommunicationException.cs
- PeerApplicationLaunchInfo.cs
- AttributeCollection.cs
- PerformanceCounterPermissionEntryCollection.cs
- ProtocolElement.cs
- TextDecorations.cs
- AssertFilter.cs
- TransformDescriptor.cs
- HttpStreamMessage.cs
- Win32.cs
- SByteConverter.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- MetadataProperty.cs
- SortableBindingList.cs
- ConvertTextFrag.cs
- ScaleTransform3D.cs
- CoTaskMemHandle.cs
- ServicesUtilities.cs
- QilReplaceVisitor.cs
- WebPartMovingEventArgs.cs
- SelectionRange.cs
- OracleCommandBuilder.cs
- ParameterCollection.cs
- BackgroundWorker.cs
- UiaCoreApi.cs
- LayoutSettings.cs
- EntityDataSourceSelectedEventArgs.cs
- TokenDescriptor.cs
- DataGridViewIntLinkedList.cs
- DataGridComboBoxColumn.cs
- SimpleMailWebEventProvider.cs
- XmlUtil.cs
- WindowsStartMenu.cs
- DoubleUtil.cs
- ActivityPropertyReference.cs
- SymbolUsageManager.cs
- XamlBuildTaskServices.cs
- OutputScope.cs
- AutoResizedEvent.cs
- DispatcherSynchronizationContext.cs
- InputMethodStateTypeInfo.cs
- ValidationResult.cs
- ErrorFormatter.cs
- ScriptManager.cs
- ListItem.cs
- StringConverter.cs
- FormViewRow.cs
- SqlClientMetaDataCollectionNames.cs
- translator.cs
- HttpServerVarsCollection.cs
- StyleSelector.cs
- TextTreeInsertUndoUnit.cs
- DigestTraceRecordHelper.cs
- linebase.cs
- CodeMethodInvokeExpression.cs
- NotSupportedException.cs
- StretchValidation.cs
- XpsResource.cs
- GroupItemAutomationPeer.cs
- PageOutputQuality.cs
- _AutoWebProxyScriptHelper.cs
- XamlSerializer.cs
- FileLevelControlBuilderAttribute.cs
- OneWayChannelListener.cs
- SystemDropShadowChrome.cs
- ProviderConnectionPoint.cs
- RegionData.cs
- PropertyInformationCollection.cs
- TokenizerHelper.cs
- ComponentResourceManager.cs
- SystemWebSectionGroup.cs
- BridgeDataReader.cs
- SelectionRangeConverter.cs
- DataTablePropertyDescriptor.cs
- GridViewRow.cs
- StreamGeometry.cs
- SiteOfOriginPart.cs
- BaseProcessor.cs
- DataObjectSettingDataEventArgs.cs
- XamlSerializationHelper.cs
- ThousandthOfEmRealDoubles.cs
- MediaPlayer.cs
- BaseProcessor.cs
- ListViewSortEventArgs.cs
- WebControlParameterProxy.cs
- OptimalTextSource.cs
- TraceListener.cs
- PersonalizationStateQuery.cs
- Rotation3DAnimation.cs