Code:
/ FX-1434 / FX-1434 / 1.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
- CompilerGlobalScopeAttribute.cs
- OciEnlistContext.cs
- DataFormats.cs
- WindowsAuthenticationModule.cs
- CrossAppDomainChannel.cs
- HtmlSelect.cs
- TreePrinter.cs
- CategoriesDocumentFormatter.cs
- ProxyOperationRuntime.cs
- SqlRetyper.cs
- SocketElement.cs
- ProvideValueServiceProvider.cs
- RequestContext.cs
- IndentedTextWriter.cs
- PieceNameHelper.cs
- SmtpNtlmAuthenticationModule.cs
- DependencyObjectPropertyDescriptor.cs
- DocumentDesigner.cs
- DrawingAttributes.cs
- CollectionDataContract.cs
- TreeNodeStyle.cs
- TextComposition.cs
- Crc32.cs
- TraceHandler.cs
- SqlVisitor.cs
- GridItem.cs
- KeyboardNavigation.cs
- ClientProtocol.cs
- SecurityContext.cs
- ActivityTrace.cs
- XmlIlVisitor.cs
- DesignTableCollection.cs
- RegexStringValidator.cs
- HeaderCollection.cs
- DictionaryMarkupSerializer.cs
- DataGridViewUtilities.cs
- SevenBitStream.cs
- TiffBitmapEncoder.cs
- SourceLineInfo.cs
- KerberosRequestorSecurityToken.cs
- ItemCheckEvent.cs
- ModuleBuilder.cs
- InheritanceRules.cs
- CommunicationObjectManager.cs
- HitTestParameters.cs
- DataKey.cs
- SyndicationPerson.cs
- ProtocolsSection.cs
- CaseKeyBox.ViewModel.cs
- CqlLexerHelpers.cs
- LicenseException.cs
- UIElement3D.cs
- ProvidersHelper.cs
- CodeAttributeArgument.cs
- GeometryValueSerializer.cs
- OdbcError.cs
- FilteredAttributeCollection.cs
- NodeFunctions.cs
- XmlSchemaAnnotated.cs
- ScriptResourceAttribute.cs
- BindingUtils.cs
- VisualBasicReference.cs
- HebrewNumber.cs
- SettingsPropertyValue.cs
- LayoutInformation.cs
- KeyFrames.cs
- CodeAccessSecurityEngine.cs
- ProcessModelInfo.cs
- CommandBindingCollection.cs
- ColumnWidthChangedEvent.cs
- FixedNode.cs
- ProcessingInstructionAction.cs
- CompilationLock.cs
- StyleXamlTreeBuilder.cs
- Win32Interop.cs
- HttpCapabilitiesEvaluator.cs
- ApplicationServiceHelper.cs
- PerfCounters.cs
- DBSchemaTable.cs
- IssuanceLicense.cs
- DataGridViewCellStyleConverter.cs
- HealthMonitoringSection.cs
- SQLMoneyStorage.cs
- BamlMapTable.cs
- ToggleProviderWrapper.cs
- ScriptHandlerFactory.cs
- DataColumnPropertyDescriptor.cs
- ComplexBindingPropertiesAttribute.cs
- MessagingDescriptionAttribute.cs
- WebPartConnectVerb.cs
- ChtmlLinkAdapter.cs
- FileChangesMonitor.cs
- XmlTextReaderImpl.cs
- _SpnDictionary.cs
- DSACryptoServiceProvider.cs
- GPStream.cs
- CodeAssignStatement.cs
- CollectionTypeElement.cs
- MethodCallConverter.cs
- TextServicesCompartmentEventSink.cs