/// <inheritdoc />
        public async Task <TReturnType> DeserializeAsync <TReturnType>(IResponseBodyReader reader)
        {
            string json = await reader.ReadAsStringAsync()
                          .ConfigureAwait(false);

            return(JsonConvert.DeserializeObject <TReturnType>(json));
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public async Task <TReturnType> DeserializeAsync <TReturnType>(IResponseBodyReader reader)
        {
            string xml = await reader.ReadAsStringAsync();

            //TODO: Can or should this be done async too?
            XmlSerializer serializer = new XmlSerializer(typeof(TReturnType));

            using (StringReader stringReader = new StringReader(xml))
            {
                using (XmlReader xmlReader = XmlReader.Create(stringReader))
                {
                    return((TReturnType)serializer.Deserialize(xmlReader));
                }
            }
        }
Ejemplo n.º 3
0
 /// <inheritdoc />
 public async Task <TReturnType> DeserializeAsync <TReturnType>(IResponseBodyReader reader)
 {
     //This is ugly but we should TRUST that the caller knows what they are doing
     //but it is very likely that the TReturnType is a string
     return((TReturnType)(object)await reader.ReadAsStringAsync().ConfigureAwait(false));
 }