Esempio n. 1
0
            public async Task WriteToCacheAsync(string cacheKey, string content)
            {
                var response = new HttpResponseMessage
                {
                    Content = new StringContent(content, Encoding.UTF8)
                };

                using (response)
                    using (var sourceCacheContext = new SourceCacheContext())
                    {
                        var httpSourceCacheContext = HttpSourceCacheContext.Create(sourceCacheContext, retryCount: 0);

                        var result = HttpCacheUtility.InitializeHttpCacheResult(
                            TestDirectory,
                            new Uri(FakeSource),
                            cacheKey,
                            httpSourceCacheContext);

                        await HttpCacheUtility.CreateCacheFileAsync(
                            result,
                            response,
                            stream => { },
                            CancellationToken.None);

                        result.Stream.Dispose();
                    }
            }
Esempio n. 2
0
 private HttpCacheResult InitializeHttpCacheResult(PackageIdentity identity, SourceCacheContext sourceCacheContext)
 {
     return(HttpCacheUtility.InitializeHttpCacheResult(
                NuGetExe.GetHttpCachePath(this),
                new Uri(CurrentSource),
                $"nupkg_{identity.Id}.{identity.Version}",
                HttpSourceCacheContext.Create(sourceCacheContext, retryCount: 0)));
 }
 public HttpCacheResult InitializeHttpCacheResult(string httpCacheDirectory, Uri sourceUri, string cacheKey, HttpSourceCacheContext context)
 {
     return(HttpCacheUtility.InitializeHttpCacheResult(
                httpCacheDirectory,
                sourceUri,
                cacheKey,
                context));
 }