Exemplo n.º 1
0
        public List <Message> GetMostRecent()
        {
            if (_simulateErrors)
            {
                throw new ApplicationException("Simulated network failure");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Began downloading");

                var client  = new WebClient();
                var content = client.DownloadString("http://localhost:8080/Messages");

                System.Diagnostics.Debug.WriteLine("Download succeeded");

                using (var r = new StringReader(content)) {
                    using (var xr = new XmlTextReader(r)) {
                        return(Message.ReadAllXml(xr).ToList());
                    }
                }
            }
        }