Create() public method

public Create ( string name = null ) : Storage
name string
return NuGet.Services.Metadata.Catalog.Persistence.Storage
示例#1
0
        async Task CreateIndex(CancellationToken cancellationToken)
        {
            var index = new Index();

            string queryResource = new Uri(_baseAddress, "query").AbsoluteUri;

            index.Add(queryResource, "@type", "SearchQueryService/3.0.0-beta");
            index.Add(queryResource, "comment", "Query endpoint of NuGet Search service (primary)");

            string flatContainerResource = new Uri(_baseAddress, Flat).AbsoluteUri;

            index.Add(flatContainerResource, "@type", "PackageBaseAddress/3.0.0");
            index.Add(flatContainerResource, "comment", "Base URL of Azure storage where NuGet package registration info for DNX is stored");

            string registrationsBaseUrlResource = new Uri(_baseAddress, Registration).AbsoluteUri;

            index.Add(registrationsBaseUrlResource, "@type", "RegistrationsBaseUrl/3.0.0-beta");
            index.Add(registrationsBaseUrlResource, "comment", "Base URL of Azure storage where NuGet package registration info is stored used by Beta clients");

            string reportAbuseResource = "https://www.nuget.org/packages/{id}/{version}/ReportAbuse";

            index.Add(reportAbuseResource, "@type", "ReportAbuseUriTemplate/3.0.0-beta");
            index.Add(reportAbuseResource, "comment", "URI template used by NuGet Client to construct Report Abuse URL for packages");

            var factory = new MemoryStorageFactory(_baseAddress, _store);
            var storage = factory.Create();

            await storage.Save(new Uri(_baseAddress, "index.json"), new StringStorageContent(index.ToJson(), "application/json"), cancellationToken);
        }
示例#2
0
        public async Task Load(string path, CancellationToken cancellationToken)
        {
            var directoryInfo = new DirectoryInfo(path);

            foreach (var fileInfo in directoryInfo.EnumerateFiles("*.nuspec"))
            {
                AddNuspec(fileInfo);
            }

            //  Catalog

            var factory = new MemoryStorageFactory(new Uri(_baseAddress, Catalog), _store);
            var storage = factory.Create();

            var catalog = new AppendOnlyCatalogWriter(storage);

            foreach (var registration in Data.Values)
            {
                foreach (var package in registration.Values)
                {
                    var metadata = new NupkgMetadata
                    {
                        Nuspec = package
                    };
                    catalog.Add(new PackageCatalogItem(metadata));
                }
            }

            await catalog.Commit(null, cancellationToken);

            Uri catalogIndex = new Uri(storage.BaseAddress, "index.json");

            Func <StorageHttpMessageHandler> handlerFunc = () => { return(new StorageHttpMessageHandler(storage)); };

            await CreateRegistrationBlobs(catalogIndex, handlerFunc, cancellationToken);
            await CreateFlatContainer(catalogIndex, handlerFunc, cancellationToken);
            await CreateLuceneIndex(catalogIndex, handlerFunc, cancellationToken);
            await CreateIndex(cancellationToken);
        }
示例#3
0
文件: State.cs 项目: NuGet/Entropy
        public async Task Load(string path, CancellationToken cancellationToken)
        {
            var directoryInfo = new DirectoryInfo(path);

            foreach (var fileInfo in directoryInfo.EnumerateFiles("*.nuspec"))
            {
                AddNuspec(fileInfo);
            }

            //  Catalog

            var factory = new MemoryStorageFactory(new Uri(_baseAddress, Catalog), _store);
            var storage = factory.Create();

            var catalog = new AppendOnlyCatalogWriter(storage);

            foreach (var registration in Data.Values)
            {
                foreach (var package in registration.Values)
                {
                    var metadata = new NupkgMetadata
                    {
                        Nuspec = package
                    };
                    catalog.Add(new PackageCatalogItem(metadata));
                }
            }

            await catalog.Commit(null, cancellationToken);

            Uri catalogIndex = new Uri(storage.BaseAddress, "index.json");

            Func<StorageHttpMessageHandler> handlerFunc = () => { return new StorageHttpMessageHandler(storage); };

            await CreateRegistrationBlobs(catalogIndex, handlerFunc, cancellationToken);
            await CreateFlatContainer(catalogIndex, handlerFunc, cancellationToken);
            await CreateLuceneIndex(catalogIndex, handlerFunc, cancellationToken);
            await CreateIndex(cancellationToken);
        }
示例#4
0
        public Storage CreateStorage()
        {
            var factory = new MemoryStorageFactory(_baseAddress, _store);

            return(factory.Create());
        }
示例#5
0
文件: State.cs 项目: NuGet/Entropy
        async Task CreateIndex(CancellationToken cancellationToken)
        {
            var index = new Index();

            string queryResource = new Uri(_baseAddress, "query").AbsoluteUri;
            index.Add(queryResource, "@type", "SearchQueryService/3.0.0-beta");
            index.Add(queryResource, "comment", "Query endpoint of NuGet Search service (primary)");

            string flatContainerResource = new Uri(_baseAddress, Flat).AbsoluteUri;
            index.Add(flatContainerResource, "@type", "PackageBaseAddress/3.0.0");
            index.Add(flatContainerResource, "comment", "Base URL of Azure storage where NuGet package registration info for DNX is stored");

            string registrationsBaseUrlResource = new Uri(_baseAddress, Registration).AbsoluteUri;
            index.Add(registrationsBaseUrlResource, "@type", "RegistrationsBaseUrl/3.0.0-beta");
            index.Add(registrationsBaseUrlResource, "comment", "Base URL of Azure storage where NuGet package registration info is stored used by Beta clients");

            string reportAbuseResource = "https://www.nuget.org/packages/{id}/{version}/ReportAbuse";
            index.Add(reportAbuseResource, "@type", "ReportAbuseUriTemplate/3.0.0-beta");
            index.Add(reportAbuseResource, "comment", "URI template used by NuGet Client to construct Report Abuse URL for packages");

            var factory = new MemoryStorageFactory(_baseAddress, _store);
            var storage = factory.Create();

            await storage.Save(new Uri(_baseAddress, "index.json"), new StringStorageContent(index.ToJson(), "application/json"), cancellationToken);
        }
示例#6
0
文件: State.cs 项目: NuGet/Entropy
 public Storage CreateStorage()
 {
     var factory = new MemoryStorageFactory(_baseAddress, _store);
     return factory.Create();
 }