private CdnjsCatalog SetupCatalog(ICacheService testCacheService = null, Dictionary <string, string> prepopulateCacheFiles = null) { string projectFolder = Path.Combine(Path.GetTempPath(), "LibraryManager"); string cacheFolder = Environment.ExpandEnvironmentVariables(@"%localappdata%\Microsoft\Library\"); var hostInteraction = new HostInteraction(projectFolder, cacheFolder); ICacheService cacheService = testCacheService ?? new Mock <ICacheService>().SetupCatalog() .SetupSampleLibrary() .Object; if (prepopulateCacheFiles != null) { foreach (KeyValuePair <string, string> item in prepopulateCacheFiles) { // put the provider IdText into the path to mimic the provider implementation string filePath = Path.Combine(cacheFolder, CdnjsProvider.IdText, item.Key); string directoryPath = Path.GetDirectoryName(filePath); Directory.CreateDirectory(directoryPath); File.WriteAllText(filePath, item.Value); _prepopulatedFiles.Add(filePath); } } var provider = new CdnjsProvider(hostInteraction, cacheService: null); return(new CdnjsCatalog(provider, cacheService, new VersionedLibraryNamingScheme())); }
private CdnjsCatalog Initialize() { string projectFolder = Path.Combine(Path.GetTempPath(), "LibraryManager"); string cacheFolder = Environment.ExpandEnvironmentVariables(@"%localappdata%\Microsoft\Library\"); var hostInteraction = new HostInteraction(projectFolder, cacheFolder); var cacheService = new FakeCdnjsCacheService(); var provider = new CdnjsProvider(hostInteraction, cacheService: null); return(new CdnjsCatalog(provider, cacheService, new VersionedLibraryNamingScheme())); }
static async System.Threading.Tasks.Task SetDefaults() { Defaults.CachePath = Options.CachePath; Defaults.CacheDays = Options.CacheDays; IPackageProvider provider; // TODO: get rid of the enum and make this dynamic and MEF'ed out if (Options.Provider == Providers.JsDelivr) { provider = new JsDelivrProvider(); } else { provider = new CdnjsProvider(); } Manager = new Manager(provider); if (!provider.IsInitialized) { await provider.InitializeAsync(); } }