Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
116 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ ServiceHost Language="C#" Debug="true" Service="NuGetGallery.V2Feed" CodeBehind="V2CuratedFeed.svc.cs" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Data.Entity; | ||
using System.Data.Services; | ||
using System.Linq; | ||
using System.ServiceModel.Web; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
using System.Web.Routing; | ||
|
||
namespace NuGetGallery | ||
{ | ||
public class V2CuratedFeed : FeedServiceBase<V2FeedPackage> | ||
{ | ||
private const int FeedVersion = 2; | ||
|
||
public V2CuratedFeed() | ||
{ | ||
|
||
} | ||
|
||
public V2CuratedFeed(IEntitiesContext entities, IEntityRepository<Package> repo, IConfiguration configuration, ISearchService searchSvc) | ||
: base(entities, repo, configuration, searchSvc) | ||
{ | ||
} | ||
|
||
protected override FeedContext<V2FeedPackage> CreateDataSource() | ||
{ | ||
var packages = GetPackages(); | ||
|
||
return new FeedContext<V2FeedPackage> | ||
{ | ||
Packages = packages.ToV2FeedPackageQuery(Configuration.SiteRoot) | ||
}; | ||
} | ||
|
||
[WebGet] | ||
public IQueryable<V2FeedPackage> FindPackagesById(string id) | ||
{ | ||
return GetPackages() | ||
.Where(p => p.PackageRegistration.Id.Equals(id, StringComparison.OrdinalIgnoreCase)) | ||
.ToV2FeedPackageQuery(Configuration.SiteRoot); | ||
} | ||
|
||
public IQueryable<Package> GetPackages() | ||
{ | ||
string curatedFeed = HttpContext.Current.Request.QueryString["name"]; | ||
if (curatedFeed == null) | ||
throw new Exception(); | ||
|
||
return Entities.CuratedFeeds | ||
.Where(cf => cf.Name == curatedFeed) | ||
.Include(cf => cf.Packages.Select(cp => cp.PackageRegistration.Packages)) | ||
.SelectMany(cf => cf.Packages.SelectMany(cp => cp.PackageRegistration.Packages.Select(p => p))); | ||
} | ||
|
||
[WebGet] | ||
public IQueryable<V2FeedPackage> Search(string searchTerm, string targetFramework, bool includePrerelease) | ||
{ | ||
var packages = GetPackages(); | ||
|
||
packages = packages.Where(p => p.Listed); | ||
if (!includePrerelease) | ||
{ | ||
packages = packages.Where(p => !p.IsPrerelease); | ||
} | ||
return packages.Search(searchTerm).ToV2FeedPackageQuery(Configuration.SiteRoot); | ||
} | ||
|
||
public override Uri GetReadStreamUri( | ||
object entity, | ||
DataServiceOperationContext operationContext) | ||
{ | ||
var package = (V2FeedPackage)entity; | ||
var httpContext = new HttpContextWrapper(HttpContext.Current); | ||
var urlHelper = new UrlHelper(new RequestContext(httpContext, new RouteData())); | ||
|
||
string url = urlHelper.PackageDownload(FeedVersion, package.Id, package.Version); | ||
|
||
return new Uri(url, UriKind.Absolute); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters