public List <T> listar <T>(Uri uriBase)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(
                new Uri(uriBase, "json"));

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "GET";

            string resposta = Requisicao.realizarSemConteudo(httpWebRequest);

            return(JsonConvert.DeserializeObject <List <T> >(resposta));
        }
示例#2
0
        public List <T> listar <T>(Uri uriBase)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(
                new Uri(uriBase, "xml"));

            httpWebRequest.ContentType = "application/xml";
            httpWebRequest.Method      = "GET";

            string resposta = Requisicao.realizarSemConteudo(httpWebRequest);

            XmlSerializer serializador = new XmlSerializer(typeof(List <T>), new XmlRootAttribute("list"));
            StringReader  leitorString = new StringReader(resposta);
            XmlTextReader leitorXml    = new XmlTextReader(leitorString);

            return(serializador.Deserialize(leitorXml) as List <T>);
        }