Example #1
0
        public Result NewStory(Rss.Items items, string imagePath)
        {
            Result newStory = new Result();  // Opretter resultat til listen

            newStory.Title    = items.Title; // Sætter title
            newStory.SubTitle = items.Date.ToString();
            newStory.IcoPath  = imagePath;

            newStory.Action = context => // sætter action på hver story
            {
                // Do something
                System.Diagnostics.Process.Start(items.Link); // open browser

                return(true);                                 // True bestemmer at wox skal lukke, når man trykker på story
            };
            return(newStory);
        }
Example #2
0
        public Collection <Rss.Items> GetFeed()
        {
            // Check to see if the feed URL is empty
            if (string.IsNullOrEmpty(Url))
            {
                // Throw an exception if not provided
                throw new ArgumentException("You must provide a feed url");
            }

            //Start parsing process
            using (XmlReader reader = XmlReader.Create(Url))
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(reader);
                // Parse the items of the feed
                ParseDocElements(xmlDoc.SelectSingleNode("//channel"), "title", ref _feedTitle);
                ParseDocElements(xmlDoc.SelectSingleNode("//channel"), "description", ref _feedDescription);
                _rssItems.Clear();
                XmlNodeList nodes = xmlDoc.SelectNodes("rss/channel/item");

                foreach (XmlNode node in nodes)
                {
                    Rss.Items item = new Rss.Items();
                    ParseDocElements(node, "title", ref item.Title);
                    ParseDocElements(node, "description", ref item.Description);
                    ParseDocElements(node, "link", ref item.Link);

                    string date = null;
                    ParseDocElements(node, "pubDate", ref date);
                    DateTime.TryParse(date, out item.Date);

                    _rssItems.Add(item);
                }

                return(_rssItems);
            }
        }