예제 #1
0
 /// <summary>
 /// Remove feed url from list of Urls
 /// </summary>
 /// <param name="url"></param>
 public void RemoveFeed(string url)
 {
     if (FeedUrls.Contains(url))
     {
         FeedUrls.Remove(url);
     }
 }
예제 #2
0
        /// <summary>
        /// Adding new feed if it exists.
        /// </summary>
        /// <param name="url">feed url</param>
        /// <returns></returns>
        public async Task SubscribeToFeedAsync(string url)
        {
            //getting feed links from HTML page
            string[] links = await HttpHelper.ParseFeedUrlsAsStringAsync(url);

            if (links.Length == 0)
            {
                try
                {
                    await AddNewFeedAsync(url);

                    FeedUrls.Add(url);
                }
                catch
                {
                    throw new Exception("Failed to find feed.\nTry checking the link.");
                }
            }
            else
            {
                //adding all feeds from found links
                foreach (string link in links)
                {
                    if (!FeedUrls.Contains(link))
                    {
                        try
                        {
                            await AddNewFeedAsync(link);
                        }
                        catch
                        {
                            throw new Exception("Couldn't find resource.");
                        }
                        FeedUrls.Add(link);
                    }
                }
            }
        }