Beispiel #1
0
        public IEnumerable<IPackage> GetPackages(NamedUrl url)
        {
            try
            {
                if (url == null)
                {
                    Log.Info("Getting packages for null NamedUrl");
                    return new List<IPackage>();
                }
                Log.InfoFormat("Getting packages for feed {0}:{1}", url.Name, url.Url);
                var ret = new List<IPackage>();
                ret = PackageRepositoryFactory.Default.CreateRepository(url.Url).GetPackages().ToList();
                Log.InfoFormat("Finished getting packages for feed {0}:{1}", url.Name, url.Url);
                return ret;

            }
            finally
            {
                Log.InfoFormat("Finished");
            }
        }
Beispiel #2
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);
     }
 }
Beispiel #3
0
 public void RemoveFeed(NamedUrl feed)
 {
     lock (this)
     {
         var remList = feeds.Where(x => x.Name.Equals(feed.Name)).ToArray();
         foreach (var r in remList)
         {
             feeds.Remove(r);
         }
         this.WriteFeedList();
     }
 }
Beispiel #4
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();

            // 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.
            feed.Url = CorrectMyGetFeed(feed.Url);
            lines.ForEach(line => line.Url = CorrectMyGetFeed(line.Url));

            if (lines.Any(x => x.Name.ToLower() == feed.Name.ToLower())) return;

            lines.Add(feed);

            Stream stream = null;
            while (!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));
            }
        }
Beispiel #5
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);
     }
 }
Beispiel #6
0
 public void RemoveFeed(NamedUrl feed)
 {
     lock (this)
     {
         if( ReservedFeeds.Any( x => x.Name.Equals( feed.Name, StringComparison.InvariantCultureIgnoreCase ) ) )
             return;
         //throw new UserMessageException("Can not remove built in feeds.");
         var remList = feeds.Where(x => x.Name.Equals(feed.Name)).ToArray();
         foreach (var r in remList)
         {
             feeds.Remove(r);
         }
         this.WriteFeedList();
     }
 }
Beispiel #7
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;
     }
 }
Beispiel #8
0
 public void AddFeed(NamedUrl feed)
 {
     lock (this)
     {
         if (feed.Name.Equals("Local", StringComparison.InvariantCultureIgnoreCase) || feed.Name.Equals("OCTGN Official", StringComparison.InvariantCultureIgnoreCase))
             throw new UserMessageException("You can not replace built in feeds");
         var remList = feeds.Where(x => x.Name.Equals(feed.Name)).ToArray();
         foreach (var r in remList)
         {
             feeds.Remove(r);
         }
         feeds.Add(feed);
         this.WriteFeedList();
     }
 }
Beispiel #9
0
        public void RemoveFeed( NamedUrl feed )
        {
            lock( _feedLock ) {
                if( ReservedFeeds.Any( x => x.Name.Equals( feed.Name, StringComparison.InvariantCultureIgnoreCase ) ) )
                    return;
                NamedUrl[] remList = UserFeeds.Where( x => !x.Name.Equals( feed.Name ) ).ToArray();
                WriteFeedListToDisk( remList );

                cachedFeedsExpireDate = DateTime.MinValue; // Expire cache
            }
        }
Beispiel #10
0
        public void AddFeed( NamedUrl feed )
        {
            lock( _feedLock ) {
                if( ReservedFeeds.Any( x => x.Name.Equals( feed.Name, StringComparison.InvariantCultureIgnoreCase ) ) )
                    return;
                List<NamedUrl> newList = UserFeeds.Where( x => !x.Name.Equals( feed.Name ) )
                    .ToList();

                newList.Add( feed );
                WriteFeedListToDisk( newList );

                cachedFeedsExpireDate = DateTime.MinValue; // Expire cache
            }
        }