public MasterData(IConfiguration nugetConfig, CacheStrategy cacheStrategy) { if (nugetConfig == null) { throw new ArgumentException($"Invalid '{nameof(nugetConfig)}' argument.", nameof(nugetConfig)); } packagesPath = nugetConfig["packages"]; makeReadonly = bool.Parse(nugetConfig["makeReadonly"]); if (cacheStrategy.CacheType == CacheType.NoCacheLoadAll) { contentFacade = new LoadAllContentFacade(); } else if (cacheStrategy.CacheType == CacheType.NoCacheLoadNothing) { contentFacade = new LoadNothingContentFacade(); } else if (cacheStrategy.CacheType == CacheType.Cache) { contentFacade = new CachedContentFacade(cacheStrategy.CacheEntryExpiration); } else { throw new NotSupportedException($"Cache type '{cacheStrategy.CacheType}' not supported yet."); } ProcessPackageFiles(); WatchPackagesFolder(); }
private void Run(IConfigurationRoot config) { string appName = PlatformServices.Default.Application.ApplicationName; string appVersion = PlatformServices.Default.Application.ApplicationVersion; lock (Globals.ConsoleLock) { Console.WriteLine($"{appName} {appVersion} [commit {GitCommitInfo.ShortCommitHash}]"); Console.WriteLine(); } CacheStrategy cacheStrategy = LoadCacheStrategy(config); masterData = new MasterData(config.GetSection("nuget"), cacheStrategy); foreach (RequestProcessorBase requestProcessor in requestProcessors) { requestProcessor.Initialize(masterData); } string url = config["server:url"]; new WebHostBuilder() .UseKestrel() .UseUrls(url) .Configure(app => app.Run(OnRequest)) .Build() .Run(); }