Пример #1
0
        public PackageManagerDialogViewModel()
            : base("Packages")
        {
            _packageManager = new PackageManager(this);

            AvailablePackages = new ObservableCollection <IPackageSearchMetadata>();

            Dispatcher.UIThread.InvokeAsync(async() =>
            {
                InvalidateInstalledPackages();

                await DownloadCatalog();
            });

            InstallCommand = ReactiveCommand.Create();
            InstallCommand.Subscribe(async _ =>
            {
                await PackageManager.InstallPackage(selectedPackage.Identity.Id, selectedPackage.Identity.Version.ToFullString());

                InvalidateInstalledPackages();
            });

            UninstallCommand = ReactiveCommand.Create();
            UninstallCommand.Subscribe(async _ =>
            {
                if (SelectedInstalledPackage != null)
                {
                    await PackageManager.UninstallPackage(SelectedInstalledPackage.Model.Id, SelectedInstalledPackage.Model.Version.ToNormalizedString());

                    InvalidateInstalledPackages();
                }
            });

            OKCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.EnableInterface));

            OKCommand.Subscribe(_ =>
            {
                ShellViewModel.Instance.InvalidateCodeAnalysis();
                Close();
            });

            EnableInterface = true;
        }
Пример #2
0
        public PackageManagerDialogViewModel()
            : base("Packages")
        {
            AvailablePackages = new ObservableCollection <PackageReference>();

            DownloadCatalog();

            InstallCommand = ReactiveCommand.Create();
            InstallCommand.Subscribe(async o =>
            {
                EnableInterface = false;

                try
                {
                    await SelectedPackageIndex.Synchronize(SelectedTag, this);

                    //if (fullPackage.Install())
                    //{
                    //    Status = "Package Installed Successfully.";
                    //}
                    //else
                    //{
                    //    Status = "An error occurred trying to install package.";
                    //}
                }
                catch (Exception e)
                {
                    Status = "An error occurred trying to install package. " + e.Message;
                }

                EnableInterface = true;
            });

            OKCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.EnableInterface));

            OKCommand.Subscribe(_ =>
            {
                ShellViewModel.Instance.InvalidateCodeAnalysis();
                Close();
            });

            EnableInterface = true;
        }