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
- ValidationError.cs
- NativeMethods.cs
- HttpAsyncResult.cs
- System.Data_BID.cs
- AuthenticationException.cs
- DescendantBaseQuery.cs
- FloatSumAggregationOperator.cs
- __Filters.cs
- PartialTrustHelpers.cs
- SocketElement.cs
- DataGridColumnFloatingHeader.cs
- Expression.DebuggerProxy.cs
- PowerEase.cs
- ExpressionBinding.cs
- WmfPlaceableFileHeader.cs
- XmlObjectSerializerReadContextComplexJson.cs
- SmtpLoginAuthenticationModule.cs
- Collection.cs
- FileDialogCustomPlaces.cs
- OrCondition.cs
- EtwTrace.cs
- DragEvent.cs
- _AutoWebProxyScriptEngine.cs
- ExpressionBinding.cs
- GridViewRowCollection.cs
- EntityException.cs
- SoapExtensionTypeElementCollection.cs
- DetailsViewPageEventArgs.cs
- PointCollectionValueSerializer.cs
- XmlArrayItemAttribute.cs
- SQLDouble.cs
- BigInt.cs
- SocketInformation.cs
- IPCCacheManager.cs
- FlowDocumentPaginator.cs
- SecureUICommand.cs
- ExpandCollapsePattern.cs
- EmbossBitmapEffect.cs
- Queue.cs
- ApplicationSecurityInfo.cs
- JsonObjectDataContract.cs
- GeometryModel3D.cs
- TextMetrics.cs
- DataObject.cs
- PageRouteHandler.cs
- XhtmlBasicValidationSummaryAdapter.cs
- NotifyInputEventArgs.cs
- FunctionImportMapping.cs
- HttpRequestBase.cs
- odbcmetadatacolumnnames.cs
- CharEntityEncoderFallback.cs
- _UriTypeConverter.cs
- XmlILModule.cs
- TypeGeneratedEventArgs.cs
- UserNameSecurityTokenAuthenticator.cs
- RunWorkerCompletedEventArgs.cs
- XamlReader.cs
- OciEnlistContext.cs
- DataBindingList.cs
- OdbcCommand.cs
- XmlNamespaceMappingCollection.cs
- querybuilder.cs
- DocumentSequenceHighlightLayer.cs
- ArrangedElementCollection.cs
- SemanticAnalyzer.cs
- CodeTypeReferenceExpression.cs
- XpsFilter.cs
- EdmMember.cs
- LocationUpdates.cs
- BitmapDecoder.cs
- SortFieldComparer.cs
- ArrayList.cs
- DataIdProcessor.cs
- ConditionCollection.cs
- HtmlControl.cs
- HorizontalAlignConverter.cs
- TypeDescriptionProvider.cs
- HtmlElementCollection.cs
- SqlNamer.cs
- BitmapEffectInputConnector.cs
- basevalidator.cs
- FaultFormatter.cs
- TextParentUndoUnit.cs
- CreatingCookieEventArgs.cs
- ImageCollectionEditor.cs
- Matrix3DValueSerializer.cs
- PassportAuthentication.cs
- KeyedQueue.cs
- XmlNamespaceManager.cs
- WebExceptionStatus.cs
- JournalEntryStack.cs
- DirectoryInfo.cs
- NetNamedPipeBindingCollectionElement.cs
- DataGridAddNewRow.cs
- OperationInfo.cs
- TemplateDefinition.cs
- HostingEnvironment.cs
- AvTraceDetails.cs
- TypeInfo.cs
- isolationinterop.cs