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
- Formatter.cs
- metadatamappinghashervisitor.cs
- ConfigurationElementCollection.cs
- SynchronizedPool.cs
- SmtpFailedRecipientsException.cs
- AppDomainGrammarProxy.cs
- PlainXmlSerializer.cs
- SevenBitStream.cs
- ToolStripItemClickedEventArgs.cs
- ConfigsHelper.cs
- EdmItemError.cs
- Environment.cs
- WorkBatch.cs
- DictionaryContent.cs
- ListChunk.cs
- RegexStringValidator.cs
- AccessKeyManager.cs
- HtmlTernaryTree.cs
- Rotation3DAnimationBase.cs
- TextRange.cs
- StrongNameUtility.cs
- FormParameter.cs
- RestrictedTransactionalPackage.cs
- XPathSelfQuery.cs
- WindowsToolbarAsMenu.cs
- relpropertyhelper.cs
- WizardPanel.cs
- GetFileNameResult.cs
- InputEventArgs.cs
- LoginUtil.cs
- RegisteredScript.cs
- UserThread.cs
- DesignerHelpers.cs
- xmlfixedPageInfo.cs
- XamlValidatingReader.cs
- ECDiffieHellman.cs
- SiteIdentityPermission.cs
- InstanceData.cs
- AlternateViewCollection.cs
- RangeValueProviderWrapper.cs
- FixedBufferAttribute.cs
- HtmlWindowCollection.cs
- PerformanceCounterPermissionEntry.cs
- AnnotationResourceCollection.cs
- PtsContext.cs
- DataStorage.cs
- ExceptionRoutedEventArgs.cs
- ChtmlPhoneCallAdapter.cs
- EntityContainer.cs
- recordstatescratchpad.cs
- WebConfigurationManager.cs
- ScopelessEnumAttribute.cs
- DataSourceControlBuilder.cs
- Composition.cs
- PropertyValue.cs
- RSAPKCS1SignatureFormatter.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- Win32.cs
- TextServicesCompartment.cs
- VisualStyleElement.cs
- ProtocolsConfiguration.cs
- SqlFunctions.cs
- HostingEnvironmentException.cs
- Evaluator.cs
- CalendarAutoFormat.cs
- WorkflowInstanceQuery.cs
- httpstaticobjectscollection.cs
- ShadowGlyph.cs
- BufferBuilder.cs
- MouseCaptureWithinProperty.cs
- StopStoryboard.cs
- TreeNodeSelectionProcessor.cs
- ToolStripDropDownMenu.cs
- RpcCryptoContext.cs
- TraceSwitch.cs
- WorkflowLayouts.cs
- InstanceView.cs
- AttachmentCollection.cs
- CodeExpressionStatement.cs
- RtfFormatStack.cs
- MailAddressCollection.cs
- DesignConnectionCollection.cs
- TextPointerBase.cs
- BuildProvider.cs
- ConstructorArgumentAttribute.cs
- OneOfConst.cs
- BulletChrome.cs
- DllNotFoundException.cs
- ButtonPopupAdapter.cs
- mediapermission.cs
- ExceptionUtil.cs
- EditorPartCollection.cs
- IdentityNotMappedException.cs
- QilInvoke.cs
- ParameterEditorUserControl.cs
- embossbitmapeffect.cs
- TaskForm.cs
- Point3DValueSerializer.cs
- ReachObjectContext.cs
- BaseCollection.cs