Exemple #1
0
 private void CorrectFeedReplacements(NamedUrl url)
 {
     if (url.Name.Equals("Local", StringComparison.InvariantCultureIgnoreCase))
     {
         url.Url = Paths.Get().LocalFeedPath;
     }
     else if (url.Name.Equals("OCTGN Official", StringComparison.InvariantCultureIgnoreCase))
     {
         url.Url = Paths.Get().MainOctgnFeed;
     }
 }
Exemple #2
0
 public IEnumerable <NamedUrl> GetFeeds()
 {
     try
     {
         Log.Info("Getting feeds");
         var ret = new List <NamedUrl>();
         ret.Add(new NamedUrl("Local", Paths.Get().LocalFeedPath));
         ret.Add(new NamedUrl("OCTGN Official", Paths.Get().MainOctgnFeed));
         Log.Info("Adding remote feeds from feed file");
         ret.AddRange(this.GetFeedsList().ToList());
         Log.Info("Got remote feeds from feed file");
         return(ret);
     }
     finally
     {
         Log.Info("Finished GetFeeds");
     }
 }
Exemple #3
0
 private IEnumerable <NamedUrl> GetFeeds(bool localOnly = false)
 {
     if (DateTime.Now > nextCheck)
     {
         var ret = new List <NamedUrl>();
         ret.Add(new NamedUrl("Local", Paths.Get().LocalFeedPath));
         if (!localOnly)
         {
             ret.Add(new NamedUrl("OCTGN Official", Paths.Get().MainOctgnFeed));
             ret.AddRange(this.GetFeedsList().ToList());
         }
         feeds     = ret;
         nextCheck = DateTime.Now.AddMinutes(1);
     }
     if (!localOnly)
     {
         return(feeds.ToArray());
     }
     return(this.feeds.Where(x => x.Name == "Local").ToArray());
 }
Exemple #4
0
        internal void WriteFeedList()
        {
            var lines = Feeds.ToList();

            // correct myGet URLS -- correct them both here before the check to make sure we don't get an http and https version of the same.
            lines.ForEach(line => line.Url = CorrectMyGetFeed(line.Url));

            // Don't write local and octgn official to file
            lines = this.RemoveLocalFeeds(lines);

            Stream stream = null;

            while (!X.Instance.File.OpenFile(Paths.Get().FeedListPath, FileMode.Create, FileShare.None, TimeSpan.FromDays(1), out stream))
            {
                Thread.Sleep(10);
            }
            using (var sr = new StreamWriter(stream))
            {
                lines.ForEach(line => sr.WriteLine(line.Name + (char)1 + line.Url));
            }
        }
Exemple #5
0
        /// <summary>
        /// Remove a feed url from the feed file. This method is for internal use only, use
        /// GameFeedManager.RemoveFeed instead.
        /// </summary>
        /// <param name="feed">Feed url</param>
        public void RemoveFeed(NamedUrl feed)
        {
            var    lines  = GetFeedsList().ToList();
            Stream stream = null;

            while (!OpenFile(Paths.Get().FeedListPath, FileMode.Create, FileShare.None, TimeSpan.FromDays(1), out stream))
            {
                Thread.Sleep(10);
            }
            foreach (var l in lines
                     .ToArray()
                     .Where(l => l.Name.ToLower() == feed.Name.ToLower()))
            {
                lines.Remove(l);
            }
            using (var sr = new StreamWriter(stream))
            {
                foreach (var f in lines)
                {
                    sr.WriteLine(f.Name + (char)1 + f.Url);
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Adds a feed url to the feeds file. This method does not check the validity
        /// of the feed, you should use GameFeedManager.AddFeed instead
        /// </summary>
        /// <param name="feed">Feed url</param>
        public void AddFeed(NamedUrl feed)
        {
            var lines = GetFeedsList().ToList();

            if (lines.Any(x => x.Name.ToLower() == feed.Name.ToLower()))
            {
                return;
            }
            Stream stream = null;

            while (!OpenFile(Paths.Get().FeedListPath, FileMode.Create, FileShare.None, TimeSpan.FromDays(1), out stream))
            {
                Thread.Sleep(10);
            }
            lines.Add(feed);
            using (var sr = new StreamWriter(stream))
            {
                foreach (var f in lines)
                {
                    sr.WriteLine(f.Name + (char)1 + f.Url);
                }
            }
        }