CreateInstalled() 공개 정적인 메소드

public static CreateInstalled ( RPackage package, IRPackageManagerViewModel owner ) : RPackageViewModel
package Microsoft.R.Components.PackageManager.Model.RPackage
owner IRPackageManagerViewModel
리턴 RPackageViewModel
예제 #1
0
        private async Task LoadInstalledAndAvailablePackagesAsync()
        {
            await TaskUtilities.SwitchToBackgroundThread();

            var availablePackages = await _packageManager.GetAvailablePackagesAsync();

            var installedPackages = await _packageManager.GetInstalledPackagesAsync();

            var vmAvailablePackages = availablePackages.Select(RPackageViewModel.CreateAvailable).ToDictionary(p => p.Name);
            var vmInstalledPackages = new List <IRPackageViewModel>();

            foreach (var installedPackage in installedPackages)
            {
                RPackageViewModel vmPackage;
                if (vmAvailablePackages.TryGetValue(installedPackage.Package, out vmPackage))
                {
                    vmPackage.AddDetails(installedPackage, true);
                    vmInstalledPackages.Add(vmPackage);
                }
                else
                {
                    vmInstalledPackages.Add(RPackageViewModel.CreateInstalled(installedPackage));
                }
            }

            _installedPackages = vmInstalledPackages.OrderBy(p => p.Name).ToList();
            _availablePackages = vmAvailablePackages.Values.OrderBy(p => p.Name).ToList <IRPackageViewModel>();
        }
예제 #2
0
        private async Task LoadInstalledAndLoadedPackagesAsync(bool reload, CancellationToken cancellationToken)
        {
            await TaskUtilities.SwitchToBackgroundThread();

            var markUninstalledAndUnloadedTask = MarkUninstalledAndUnloaded(cancellationToken);
            var getInstalledPackagesTask       = _packageManager.GetInstalledPackagesAsync(cancellationToken);
            await Task.WhenAll(markUninstalledAndUnloadedTask, getInstalledPackagesTask);

            if (reload)
            {
                _installedPackages = new List <IRPackageViewModel>();
            }
            var installedPackages = getInstalledPackagesTask.Result;

            if (!_availableLock.IsSet)
            {
                var vmInstalledPackages = installedPackages
                                          .Select(package => RPackageViewModel.CreateInstalled(package, this))
                                          .OrderBy(p => p.Name)
                                          .ToList <IRPackageViewModel>();

                IdentifyRemovablePackages(vmInstalledPackages);

                await UpdateLoadedPackages(vmInstalledPackages, null, cancellationToken);

                _installedPackages = vmInstalledPackages;

                EnsureAvailablePackagesLoadedAsync(false, cancellationToken).DoNotWait();
            }
            else
            {
                var vmAvailablePackages = _availablePackages.ToDictionary(k => k.Name);
                var vmInstalledPackages = new List <IRPackageViewModel>();

                foreach (var installedPackage in installedPackages)
                {
                    IRPackageViewModel vmPackage;
                    if (vmAvailablePackages.TryGetValue(installedPackage.Package, out vmPackage))
                    {
                        vmPackage.AddDetails(installedPackage, true);
                        vmInstalledPackages.Add(vmPackage);
                    }
                    else
                    {
                        vmInstalledPackages.Add(RPackageViewModel.CreateInstalled(installedPackage, this));
                    }
                }

                IdentifyRemovablePackages(vmInstalledPackages);
                vmInstalledPackages = vmInstalledPackages.OrderBy(p => p.Name).ToList();

                await UpdateLoadedPackages(vmInstalledPackages, null, cancellationToken);

                _installedPackages = vmInstalledPackages;
            }
        }