예제 #1
0
 /// <summary>Get the serialized representation of the request body.</summary>
 /// <typeparam name="T">The request body type.</typeparam>
 /// <param name="content">The request body content.</param>
 /// <param name="request">The HTTP request to handle.</param>
 /// <param name="formatter">The media type formatter which will serialize the request body.</param>
 protected string GetSerialized <T>(T content, HttpRequestMessage request, MediaTypeFormatterBase formatter)
 {
     using MemoryStream stream = new MemoryStream();
     using StreamReader reader = new StreamReader(stream);
     formatter.Serialize(typeof(string), content, stream, request.Content, this.NullTransportContext);
     stream.Position = 0;
     return(reader.ReadToEnd());
 }
 /// <summary>Get the serialized representation of the request body.</summary>
 /// <typeparam name="T">The request body type.</typeparam>
 /// <param name="content">The request body content.</param>
 /// <param name="request">The HTTP request to handle.</param>
 /// <param name="formatter">The media type formatter which will serialize the request body.</param>
 protected string GetSerialized <T>(T content, HttpRequestMessage request, MediaTypeFormatterBase formatter)
 {
     using (MemoryStream stream = new MemoryStream())
         using (StreamReader reader = new StreamReader(stream))
         {
             formatter.Serialize(typeof(string), content, stream, request.Content, null);
             stream.Position = 0;
             return(reader.ReadToEnd());
         }
 }