PageRenderTime 23ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/WCFWebApi/src/Microsoft.Net.Http.Formatting/System/Net/Http/MultipartMemoryStreamProvider.cs

#
C# | 53 lines | 27 code | 6 blank | 20 comment | 2 complexity | 8a3daed375aaaa740a666f6c39e0d045 MD5 | raw file
 1// <copyright>
 2//   Copyright (c) Microsoft Corporation.  All rights reserved.
 3// </copyright>
 4
 5namespace System.Net.Http
 6{
 7    using System.IO;
 8    using System.Net.Http.Headers;
 9
10    /// <summary>
11    /// Provides a <see cref="IMultipartStreamProvider"/> implementation that returns a <see cref="MemoryStream"/> instance.
12    /// This facilitates deserialization or other manipulation of the contents in memory.
13    /// </summary>
14    internal class MultipartMemoryStreamProvider : IMultipartStreamProvider
15    {
16        private static MultipartMemoryStreamProvider instance = new MultipartMemoryStreamProvider();
17
18        private MultipartMemoryStreamProvider()
19        {
20        }
21
22        /// <summary>
23        /// Gets a static instance of the <see cref="MultipartMemoryStreamProvider"/>
24        /// </summary>
25        public static MultipartMemoryStreamProvider Instance
26        {
27            get
28            {
29                return MultipartMemoryStreamProvider.instance;
30            }
31        }
32
33        /// <summary>
34        /// This <see cref="IMultipartStreamProvider"/> implementation returns a <see cref="MemoryStream"/> instance.
35        /// This facilitates deserialization or other manipulation of the contents in memory. 
36        /// </summary>
37        /// <param name="headers">The header fields describing the body parts content. Looking for header fields such as 
38        /// Content-Type and Content-Disposition can help provide the appropriate stream. In addition to using the information
39        /// in the provided header fields, it is also possible to add new header fields or modify existing header fields. This can
40        /// be useful to get around situations where the Content-type may say <b>application/octet-stream</b> but based on
41        /// analyzing the <b>Content-Disposition</b> header field it is found that the content in fact is <b>application/json</b>, for example.</param>
42        /// <returns>A stream instance where the contents of a body part will be written to.</returns>
43        public Stream GetStream(HttpContentHeaders headers)
44        {
45            if (headers == null)
46            {
47                throw new ArgumentNullException("headers");
48            }
49
50            return new MemoryStream();
51        }
52    }
53}