/// <summary> /// From the supplied names selects packages that are not in the index and attempts /// to add them to the index. This typically applies to packages that were just installed. /// </summary> private async Task <IEnumerable <IPackageInfo> > TryAddMissingPackagesAsync(IEnumerable <string> packageNames) { var list = new List <IPackageInfo>(); // Do not attempt to add new package when index is still being built if (packageNames.Any() && _buildIndexLock.IsSet) { try { var installedPackages = await GetInstalledPackagesAsync(); var packagesNotInIndex = installedPackages.Where(p => packageNames.Contains(p.Package)); foreach (var p in packagesNotInIndex) { var info = new PackageInfo(_host, p.Package, p.Description, p.Version); _packages[p.Package] = info; await info.LoadFunctionsIndexAsync(); _functionIndex.RegisterPackageFunctions(info); list.Add(info); } } catch (RHostDisconnectedException) { } } return(list); }
private async Task <IEnumerable <IPackageInfo> > AddPackagesToIndexAsync(IEnumerable <RPackage> packages) { var list = new List <IPackageInfo>(); foreach (var p in packages) { var info = new PackageInfo(_host, p.Package, p.Description, p.Version); _packages[p.Package] = info; await info.LoadFunctionsIndexAsync(); _functionIndex.RegisterPackageFunctions(info); list.Add(info); } return(list); }
private async Task <IPackageInfo> TryAddNewPackageAsync(string packageName) { var packages = await GetPackagesAsync(); var package = packages.FirstOrDefault(p => p.Package.EqualsOrdinal(packageName)); if (package != null) { var p = new PackageInfo(_host, package.Package, package.Description, package.Version); await p.LoadFunctionsIndexAsync(); _packages[packageName] = p; _functionIndex.RegisterPackageFunctions(p); return(p); } return(null); }
/// <summary> /// From the supplied names selects packages that are not in the index and attempts /// to add them to the index. This typically applies to packages that were just installed. /// </summary> private async Task<IEnumerable<IPackageInfo>> TryAddMissingPackagesAsync(IEnumerable<string> packageNames) { var list = new List<IPackageInfo>(); // Do not attempt to add new package when index is still being built if (packageNames.Any() && _buildIndexLock.IsSet) { try { var installedPackages = await GetInstalledPackagesAsync(); var packagesNotInIndex = installedPackages.Where(p => packageNames.Contains(p.Package)); foreach (var p in packagesNotInIndex) { var info = new PackageInfo(_host, p.Package, p.Description, p.Version); _packages[p.Package] = info; await info.LoadFunctionsIndexAsync(); _functionIndex.RegisterPackageFunctions(info); list.Add(info); } } catch (RHostDisconnectedException) { } } return list; }