Ejemplo n.º 1
0
        private static async Task RespondNuspecAsync(
            this INugetServerProvider provider,
            HttpContext context,
            PackageBaseAddressInputModel request)
        {
            var nuspec = provider.NuspecProvider
                         .GetAll()
                         .Where(n => n.Metadata != null)
                         .Where(n => n.Metadata.Id.ToLowerInvariant() == request.Id)
                         .FirstOrDefault(n => n.Metadata.Version == request.Version);
            var nuspecRaw = await Zip.ReadNuspecRawAsync(nuspec);

            await provider.WriteRawResponseAsync(
                context, "application/xml; charset=utf8", nuspecRaw);
        }
Ejemplo n.º 2
0
 private static async Task RespondVersionsAsync(
     this INugetServerProvider provider,
     HttpContext context,
     PackageBaseAddressInputModel request)
 {
     var model = new PackageBaseAddressVersionsOutputModel
     {
         Versions = provider.NuspecProvider
                    .GetAll()
                    .Where(n => n.Metadata != null)
                    .Where(n => n.Metadata.Id.ToLowerInvariant() == request.Id)
                    .Select(n => n.Metadata.Version)
                    .OrderBy(x => (NuGetVersionString)x)
                    .ToList()
     };
     await provider.WriteJsonResponseAsync(context, model);
 }
Ejemplo n.º 3
0
        private static async Task RespondNupkgAsync(
            this INugetServerProvider provider,
            HttpContext context,
            PackageBaseAddressInputModel request)
        {
            var nupkg = provider.NuspecProvider
                        .GetAll()
                        .Where(n => n.Metadata != null)
                        .Where(n => n.Metadata.Id.ToLowerInvariant() == request.Id)
                        .Where(n => n.Metadata.Version == request.Version)
                        .FirstOrDefault()
            ;

            if (nupkg == null)
            {
                provider.RespondNotFound(context);
                return;
            }

            var fileInfo = new PhysicalFileInfo(
                new FileInfo(nupkg.FilePath));
            await context.Response.SendFileAsync(
                fileInfo, context.RequestAborted);
        }