void webclient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { WebClient wc = (WebClient)sender; // process the feed if (e.Error == null && e.Result != null) { /* THIS IS JUST FOR TESTING List<byte> chars = new List<byte>(); System.IO.StreamReader r = new System.IO.StreamReader(e.Result); using (r) { while (r.Peek() > 0) { chars.Add((byte) r.Read()); } } byte[] bytes = chars.ToArray(); string s = System.Text.Encoding.UTF8.GetString(bytes); Console.WriteLine(s); * */ FeedInfo info = null; XmlReaderSettings settings = new XmlReaderSettings(); settings.ProhibitDtd = false; using (XmlReader reader = XmlReader.Create(e.Result, settings)) { GenericFeedParser parser = new GenericFeedParser(); info = parser.Parse(reader); } if (info != null) { info.CustomTitle = this.CustomName; info.Url = this.Url; OnFeedRetrieved(info); } else { // the loader couldn't load the feed FeedErrorEventArgs args = new FeedErrorEventArgs(new FeedException(_parseErrorMessage)); OnFeedError(args); } } else { if (e.Error != null) { // there was an error returned from the call FeedErrorEventArgs args = new FeedErrorEventArgs(e.Error); OnFeedError(args); } else { // an empty stream. FeedErrorEventArgs args = new FeedErrorEventArgs(new FeedException(_nullResultErrorMessage)); OnFeedError(args); } } // restart the timer this.timer.Start(); }
void webclient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { WebClient wc = (WebClient)sender; // process the feed if (e.Error == null && e.Result != null) { /* THIS IS JUST FOR TESTING * List<byte> chars = new List<byte>(); * System.IO.StreamReader r = new System.IO.StreamReader(e.Result); * using (r) * { * while (r.Peek() > 0) * { * chars.Add((byte) r.Read()); * } * } * byte[] bytes = chars.ToArray(); * string s = System.Text.Encoding.UTF8.GetString(bytes); * Console.WriteLine(s); * */ FeedInfo info = null; XmlReaderSettings settings = new XmlReaderSettings(); settings.ProhibitDtd = false; using (XmlReader reader = XmlReader.Create(e.Result, settings)) { GenericFeedParser parser = new GenericFeedParser(); info = parser.Parse(reader); } if (info != null) { info.CustomTitle = this.CustomName; info.Url = this.Url; OnFeedRetrieved(info); } else { // the loader couldn't load the feed FeedErrorEventArgs args = new FeedErrorEventArgs(new FeedException(_parseErrorMessage)); OnFeedError(args); } } else { if (e.Error != null) { // there was an error returned from the call FeedErrorEventArgs args = new FeedErrorEventArgs(e.Error); OnFeedError(args); } else { // an empty stream. FeedErrorEventArgs args = new FeedErrorEventArgs(new FeedException(_nullResultErrorMessage)); OnFeedError(args); } } // restart the timer this.timer.Start(); }