Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Client / System / Data / Services / Client / DataServiceStreamResponse.cs / 1305376 / DataServiceStreamResponse.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// This class represents the response as a binary stream of data // and its metadata. // //--------------------------------------------------------------------- namespace System.Data.Services.Client { using System.Collections.Generic; using System.Diagnostics; using System.IO; #if !ASTORIA_LIGHT // Data.Services http stack using System.Net; #else using System.Data.Services.Http; #endif ////// Class which represents a stream response from the service. /// public sealed class DataServiceStreamResponse : IDisposable { ///The underlying web response private HttpWebResponse response; ///Lazy initialized cached response headers. private Dictionaryheaders; /// /// Constructor for the response. This method is internal since we don't want users to create instances /// of this class. /// /// The web response to wrap. internal DataServiceStreamResponse(HttpWebResponse response) { Debug.Assert(response != null, "Can't create a stream response object from a null response."); this.response = response; } ////// Returns the content type of the response stream (ex. image/png). /// If the Content-Type header was not present in the response this property /// will return null. /// public string ContentType { get { this.CheckDisposed(); return this.response.Headers[XmlConstants.HttpContentType]; } } ////// Returns the content disposition of the response stream. /// If the Content-Disposition header was not present in the response this property /// will return null. /// public string ContentDisposition { get { this.CheckDisposed(); return this.response.Headers[XmlConstants.HttpContentDisposition]; } } ////// Returns a dictionary containing all the response headers returned from the retrieve request /// to obtain the stream. /// public DictionaryHeaders { get { this.CheckDisposed(); if (this.headers == null) { this.headers = WebUtil.WrapResponseHeaders(this.response); } return this.headers; } } /// /// Returns the stream obtained from the data service. When reading from this stream /// the operations may throw if a network error occurs. This stream is read-only. /// /// Caller must call Dispose/Close on either the returned stream or on the response /// object itself. Otherwise the network connection will be left open and the caller /// might run out of available connections. /// public Stream Stream { get { this.CheckDisposed(); return this.response.GetResponseStream(); } } #region IDisposable Members ////// Disposes all resources held by this class. Namely the network stream. /// public void Dispose() { Util.Dispose(ref this.response); } #endregion ///Checks if the object has already been disposed. If so it throws the ObjectDisposedException. ///If the object has already been disposed. private void CheckDisposed() { if (this.response == null) { Error.ThrowObjectDisposed(this.GetType()); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MatrixValueSerializer.cs
- TogglePatternIdentifiers.cs
- CacheOutputQuery.cs
- PerformanceCounterPermissionEntry.cs
- FieldDescriptor.cs
- ArraySegment.cs
- RC2.cs
- HtmlElementEventArgs.cs
- GlobalAllocSafeHandle.cs
- Mutex.cs
- MetadataUtilsSmi.cs
- KeyMatchBuilder.cs
- ConfigUtil.cs
- CompositeKey.cs
- TargetControlTypeAttribute.cs
- PolicyDesigner.cs
- CommandID.cs
- Endpoint.cs
- OneOf.cs
- IgnoreSection.cs
- securitycriticaldata.cs
- BuildProviderUtils.cs
- SchemaInfo.cs
- ForAllOperator.cs
- TextEditorCharacters.cs
- DescriptionAttribute.cs
- AppDomain.cs
- GACMembershipCondition.cs
- DataListCommandEventArgs.cs
- ContextStaticAttribute.cs
- TypeKeyValue.cs
- SqlMethodTransformer.cs
- WindowsScrollBarBits.cs
- ChtmlTextBoxAdapter.cs
- NoneExcludedImageIndexConverter.cs
- DescendantOverDescendantQuery.cs
- UnsafeNativeMethods.cs
- ResourceDictionary.cs
- SecurityContextKeyIdentifierClause.cs
- StandardRuntimeEnumValidator.cs
- TextTreeUndo.cs
- WorkflowRuntimeServicesBehavior.cs
- NetworkInformationException.cs
- TransactedBatchContext.cs
- Validator.cs
- ServiceDefaults.cs
- RenderDataDrawingContext.cs
- LocatorManager.cs
- WebPageTraceListener.cs
- ParentQuery.cs
- DataGridViewRowEventArgs.cs
- PathSegmentCollection.cs
- DrawListViewItemEventArgs.cs
- DetailsViewRowCollection.cs
- Choices.cs
- StrongTypingException.cs
- Int64Converter.cs
- AppDomainManager.cs
- Mappings.cs
- Matrix3DConverter.cs
- PersonalizableAttribute.cs
- DropTarget.cs
- EntityWithChangeTrackerStrategy.cs
- CodeRegionDirective.cs
- ShaderEffect.cs
- VirtualizedCellInfoCollection.cs
- TextTreeDeleteContentUndoUnit.cs
- SolidBrush.cs
- GradientBrush.cs
- InstanceHandleReference.cs
- _ListenerAsyncResult.cs
- MessageTransmitTraceRecord.cs
- FloaterBaseParaClient.cs
- MouseCaptureWithinProperty.cs
- RegisteredHiddenField.cs
- MenuItem.cs
- RangeValuePatternIdentifiers.cs
- IisTraceWebEventProvider.cs
- UrlMappingsSection.cs
- RevocationPoint.cs
- GridLength.cs
- CheckableControlBaseAdapter.cs
- Publisher.cs
- XmlUtf8RawTextWriter.cs
- followingsibling.cs
- WpfKnownMember.cs
- GridViewItemAutomationPeer.cs
- FixedBufferAttribute.cs
- AxImporter.cs
- ConfigurationStrings.cs
- Int64KeyFrameCollection.cs
- ValidatingPropertiesEventArgs.cs
- DeferredTextReference.cs
- Binding.cs
- NeutralResourcesLanguageAttribute.cs
- PrintPageEvent.cs
- XhtmlMobileTextWriter.cs
- DoubleIndependentAnimationStorage.cs
- FrameworkRichTextComposition.cs
- ByteAnimation.cs