private void UpdateInstalledLibraries() { InstalledLibraryItems.Clear(); var directories = _directoryService.GetDirectories(PluginsDirectory); foreach (var directory in directories) { var directoryName = directory.Remove(0, PluginsDirectory.Length); // TODO: Do not pass in null here or you wont be able to uninstall the library. var libraryListItem = new LibraryListItem(null, directoryName) { ButtonText = "N/A" }; InstalledLibraryItems.Add(libraryListItem); } }
public async Task <bool> InstallLatestVersionOfLibraryAsync(LibraryListItem libraryListItem) { if (IsLibraryInstalled(libraryListItem.Library)) { return(true); } libraryListItem.ButtonText = "Installing"; await LoadSourcesAsync(); if (!TryGetLibraryWithNameAndVersion(libraryListItem.Library, out var library)) { return(false); } var absPath = _directoryService.GetDirectoryName(Assembly.GetExecutingAssembly().Location); CreateTemporaryDirectory(absPath); var zipPath = "tmp/" + library + ".zip"; var extractPath = "tmp/" + library; var toPath = PluginsDirectory + library; await _webResourceFetcher.DownloadFileAsync(library.DownloadPath, zipPath); ExtractDllFromZip(zipPath, extractPath, toPath); library.PathOnDisk = toPath; _pluginLoader.AddPluginFromDirectory(absPath + "/" + toPath, library); UpdateInstalledLibraries(); InstalledLibraryItems.Add(new LibraryListItem(library, library.Name) { ButtonText = "Uninstall" }); libraryListItem.ButtonText = "Installed"; return(true); }