Exemplo n.º 1
0
 private async Task <T> ReadAsJsonAsync <T>(HttpContent content)
 {
     using (var stream = await content.ReadAsStreamAsync().ConfigureAwait(false))
         using (var reader = new StreamReader(stream))
             using (var jsonReader = new JsonTextReader(reader))
             {
                 return(MandrillSerializer <T> .Deserialize(jsonReader));
             }
 }
Exemplo n.º 2
0
        private StreamContent GetStreamContent <T>(T value, StreamWriter writer)
        {
            using (var jsonWriter = new JsonTextWriter(writer)
            {
                CloseOutput = false
            })
            {
                MandrillSerializer <T> .Serialize(jsonWriter, value);

                jsonWriter.Flush();
            }
            writer.BaseStream.Seek(0, SeekOrigin.Begin);
            var content = new StreamContent(writer.BaseStream);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            return(content);
        }
Exemplo n.º 3
0
 public static List <MandrillSyncEvent> ParseSyncEvents(string json)
 {
     using (var jsonTextReader = new JsonTextReader(new StringReader(json)))
         return(MandrillSerializer <List <MandrillSyncEvent> > .Deserialize(jsonTextReader));
 }