示例#1
0
        /// <summary>
        /// This takes an existing package object and creates a package model from it and inserts it into the feed.
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        public AtomItem Add(Package package)
        {
            var item = new AtomItem(package);

            Items = Items.Union(item.SingleItemAsEnumerable()).ToArray();
            return(item);
        }
示例#2
0
 public AtomItem Add(AtomItem item)
 {
     lock (this) {
         Items = Items.Where(each => each.Id != item.Id).Union(item.SingleItemAsEnumerable()).ToArray();
         return(item);
     }
 }
示例#3
0
 /// <summary>
 ///   This adds a new package model to the feed. The package model doesn't have to be completed when added, but the caller must fill in the values before the feed is generated, or it's kinda pointless. :) Use this when trying to create feeds.
 /// </summary>
 /// <param name="model"> </param>
 /// <returns> </returns>
 public AtomItem Add(PackageModel model)
 {
     lock (this) {
         var item = new AtomItem(model);
         Items = Items.Where(each => each.Id != item.Id).Union(item.SingleItemAsEnumerable()).ToArray();
         return(item);
     }
 }
示例#4
0
        private void InsertIntoFeed(CanonicalName pkgCanonicalName, FourPartVersion pkgVersion, Uri location, AtomItem item = null) {
            FeedBlob.Lock(blob => {
                // update the feed
                var feed = new AtomFeed();

                //load the feed from the _canonicalFeedUrl if we can
                try {
                    var originalFeed = LoadFeed(blob);

                    foreach (AtomItem i in originalFeed.Items.Where(each => each is AtomItem)) {
                        if (_feedName == "current") {
                            // if an older version of this package is in the current feed, 
                            if (i.Model.CanonicalName.DiffersOnlyByVersion(pkgCanonicalName) && i.Model.CanonicalName.Version < pkgVersion) {
                                // push it to the archive feed.
                                try {
                                    if (FeedHandlers["archive"] != null) {
                                        FeedHandlers["archive"].InsertIntoFeed(i.Model.CanonicalName, i.Model.Version, i.Model.Locations[0]);
                                        // and skip it
                                        continue;
                                    }
                                } catch {
                                    
                                }
                            }
                        }
                        feed.Add(i);
                    }
                } catch {
                }
                item = item ?? _packageManager.GetAtomItem(pkgCanonicalName).Result;

                if (item != null) {
                    // first, make sure that the feeds contains the intended feed location.

                    item.Model.Feeds = item.Model.Feeds ?? new XList<Uri>();
                    if (!item.Model.Feeds.Contains(_canonicalFeedUrl)) {
                        item.Model.Feeds.Insert(0, _canonicalFeedUrl);
                    }

                    item.Model.Locations = item.Model.Locations ?? new XList<Uri>();
                    if (!item.Model.Locations.Contains(location)) {
                        item.Model.Locations.Insert(0, location);
                    }

                    // drop dead urls
                    item.Model.Feeds = item.Model.Feeds.Distinct().Where(Peek).ToXList();
                    item.Model.Locations = item.Model.Locations.Distinct().Where(Peek).ToXList();
                    foreach (var l in item.Links.ToArray().Where(each => !Peek(each.Uri))) {
                        item.Links.Remove(l);
                    }

                    if (item.Model.Locations.Any()) {
                        // if we've got at least one valid location, add the item to the feed.
                        feed.Add(item);
                    }
                }
                SaveFeed(blob, feed);

                // regenerate the webpi feed based on the items in this feed
                SaveWebPiFeed(feed);
            });
        }
示例#5
0
 /// <summary>
 /// This takes an existing package object and creates a package model from it and inserts it into the feed.
 /// </summary>
 /// <param name="package"></param>
 /// <returns></returns>
 public AtomItem Add(Package package)
 {
     var item = new AtomItem(package);
     Items = Items.Union(item.SingleItemAsEnumerable()).ToArray();
     return item;
 }
示例#6
0
 public AtomItem Add(AtomItem item)
 {
     lock (this) {
         Items = Items.Where(each => each.Id != item.Id).Union(item.SingleItemAsEnumerable()).ToArray();
         return item;
     }
 }
示例#7
0
 /// <summary>
 ///   This adds a new package model to the feed. The package model doesn't have to be completed when added, but the caller must fill in the values before the feed is generated, or it's kinda pointless. :) Use this when trying to create feeds.
 /// </summary>
 /// <param name="model"> </param>
 /// <returns> </returns>
 public AtomItem Add(PackageModel model)
 {
     lock (this) {
         var item = new AtomItem(model);
         Items = Items.Where(each => each.Id != item.Id).Union(item.SingleItemAsEnumerable()).ToArray();
         return item;
     }
 }