コード例 #1
0
        public async System.Threading.Tasks.Task OnLoadedAsync()
        {
            var toolchain = OptionsModel.Toolchain;

            if (!await Rustup.HasToolchain(toolchain))
            {
                var infoBar = new VsUtilities.InfoBar($"configured toolchain {toolchain} is not installed", new VsUtilities.InfoBarButton("Install"));
                if (await Utilities.WaitForSingleButtonInfoBarAsync(infoBar))
                {
                    var task = Rustup.InstallToolchain(toolchain).ContinueWith(t => t.Result == 0);
                    await VsUtilities.CreateTask($"Installing {toolchain}", task);

                    if (!await task)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            if (!await Rustup.HasComponent("rls-preview", toolchain))
            {
                if (!await InstallComponent("rls-preview", toolchain))
                {
                    return;
                }
            }

            if (!await Rustup.HasComponent("rust-analysis", toolchain))
            {
                if (!await InstallComponent("rust-analysis", toolchain))
                {
                    return;
                }
            }

            if (!await Rustup.HasComponent("rust-src", toolchain))
            {
                if (!await InstallComponent("rust-src", toolchain))
                {
                    return;
                }
            }

            if (StartAsync != null)
            {
                await StartAsync.InvokeAsync(this, EventArgs.Empty);
            }
        }
コード例 #2
0
        private async Task <bool> InstallComponent(string component, string toolchain)
        {
            var infoBar = new VsUtilities.InfoBar($"component '{component}' is not installed", new VsUtilities.InfoBarButton("Install"));

            if (await Utilities.WaitForSingleButtonInfoBarAsync(infoBar))
            {
                var task = Rustup.InstallComponent(component, toolchain).ContinueWith(t => t.Result == 0);
                await VsUtilities.CreateTask($"Installing {component}", task);

                return(await task);
            }
            else
            {
                return(false);
            }
        }