Code:
/ 4.0 / 4.0 / 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. //---------------------------------------------------------------------- //// 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
- SqlParameter.cs
- ObjectMaterializedEventArgs.cs
- BasePattern.cs
- XmlAttributeAttribute.cs
- UrlMappingCollection.cs
- ScopelessEnumAttribute.cs
- DbReferenceCollection.cs
- DataGridViewRowPostPaintEventArgs.cs
- BaseConfigurationRecord.cs
- OleDbTransaction.cs
- TypeConverterHelper.cs
- CommandManager.cs
- Transform3DGroup.cs
- ExternalCalls.cs
- TimeSpanOrInfiniteValidator.cs
- DSASignatureDeformatter.cs
- FileIOPermission.cs
- BindToObject.cs
- CodeCompiler.cs
- CornerRadiusConverter.cs
- AppModelKnownContentFactory.cs
- XdrBuilder.cs
- IPipelineRuntime.cs
- CriticalExceptions.cs
- ScrollChrome.cs
- SignatureDescription.cs
- CodeDomConfigurationHandler.cs
- EnumMemberAttribute.cs
- _DigestClient.cs
- OutOfProcStateClientManager.cs
- COM2IPerPropertyBrowsingHandler.cs
- ConfigurationErrorsException.cs
- ListViewSelectEventArgs.cs
- SessionSymmetricMessageSecurityProtocolFactory.cs
- IndicCharClassifier.cs
- RewritingProcessor.cs
- TreeViewDesigner.cs
- HuffmanTree.cs
- SafeLibraryHandle.cs
- XmlArrayItemAttribute.cs
- UiaCoreApi.cs
- ConfigurationStrings.cs
- LocalIdKeyIdentifierClause.cs
- CryptoApi.cs
- SqlIdentifier.cs
- XmlSerializableReader.cs
- SqlFacetAttribute.cs
- HyperlinkAutomationPeer.cs
- SectionInput.cs
- MouseActionConverter.cs
- UserControlBuildProvider.cs
- ObjectRef.cs
- _LoggingObject.cs
- TypeBuilder.cs
- NamespaceList.cs
- PersonalizationEntry.cs
- MatchingStyle.cs
- XmlHelper.cs
- ComEventsInfo.cs
- RemotingConfigParser.cs
- WindowsTreeView.cs
- StatusBarItemAutomationPeer.cs
- DropShadowEffect.cs
- CqlParser.cs
- HTTPNotFoundHandler.cs
- PropertyConverter.cs
- MasterPageBuildProvider.cs
- AttributeEmitter.cs
- CharAnimationBase.cs
- PrintEvent.cs
- Literal.cs
- SplitterCancelEvent.cs
- WindowsSysHeader.cs
- InternalsVisibleToAttribute.cs
- HiddenFieldPageStatePersister.cs
- NativeMethodsCLR.cs
- SizeF.cs
- UICuesEvent.cs
- InvalidPrinterException.cs
- ObjectDataSourceSelectingEventArgs.cs
- CapabilitiesSection.cs
- UniqueIdentifierService.cs
- CounterSampleCalculator.cs
- Context.cs
- SqlSelectStatement.cs
- ListBoxItemAutomationPeer.cs
- WebConfigurationHost.cs
- EventProviderWriter.cs
- ParallelTimeline.cs
- MediaElementAutomationPeer.cs
- WebAdminConfigurationHelper.cs
- safesecurityhelperavalon.cs
- HitTestWithGeometryDrawingContextWalker.cs
- PublisherMembershipCondition.cs
- EntityCommand.cs
- XamlStream.cs
- Int16Converter.cs
- RealizationDrawingContextWalker.cs
- XmlNode.cs
- PrinterResolution.cs