Esempio n. 1
0
        protected override void Initialize()
        {
            base.Initialize();

            PaketOutputPane.SetServiceProvider(this);
            var tracker            = new ActiveGraphNodeTracker(this);
            var menuCommandService = (OleMenuCommandService)GetService(typeof(IMenuCommandService));

            commandService = new PaketMenuCommandService(this, menuCommandService, tracker);
            commandService.Register();

            PaketErrorPane.SetServiceProvider(this);
            SolutionExplorerExtensions.SetServiceProvider(this);
            StatusBarService.SetServiceProvider(this);

            packageRestorer = new PackageRestorer(
                new AutoRestorer(
                    new OutputPaneRestorer(
                        new WaitDialogRestorer(
                            new ErrorReportRestorer(
                                new PaketRestorer()
                                ),
                            (IVsThreadedWaitDialogFactory)
                            GetService(typeof(SVsThreadedWaitDialogFactory))))
                    , new PaketSettings(new ShellSettingsManager(this))
                    ));
        }
        public void Restore(IEnumerable <RestoringProject> project)
        {
            string PaketSubCommand = "restore";

            foreach (RestoringProject p in project)
            {
                PaketSubCommand += $" --references-file {p.ReferenceFile} ";
            }

            PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), PaketSubCommand,
                                      (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
        }
Esempio n. 3
0
        private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            var menuItem = (OleMenuCommand)sender;

            menuItem.Visible = false;

            SolutionExplorerExtensions.LoadSelectedItemPath();

            if (CanGenerateApplyMissingParameters())
            {
                menuItem.Visible = true;
            }
        }
Esempio n. 4
0
        private void Restore()
        {
            var dir          = SolutionExplorerExtensions.GetSolutionDirectory();
            var dependencies = Dependencies.Locate(dir);

            var projects = SolutionExplorerExtensions.GetAllProjects()
                           .Select(p => new { ProjectName = p.Name, ReferenceFile = ProjectFile.FindReferencesFile(new FileInfo(p.FullName)) })
                           .Where(p => FSharpOption <string> .get_IsSome(p.ReferenceFile))
                           .Select(p => new RestoringProject(p.ProjectName, p.ReferenceFile.Value))
                           .ToList();

            restorer.Restore(dependencies, projects);
        }
        private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            var menuItem = (OleMenuCommand)sender;

            menuItem.Visible = false;

            SolutionExplorerExtensions.LoadSelectedItemPath();

            if (NeedsInitialization())
            {
                menuItem.Visible = true;
            }
        }
Esempio n. 6
0
        public static void ShowAddPackageDialog(string selectedFileName, string projectGuid = null)
        {
            Paket.Dependencies dependenciesFile = null;

            try
            {
                dependenciesFile = Dependencies.Locate(selectedFileName);
            }
            catch (Exception)
            {
                var dir = new System.IO.FileInfo(SolutionExplorerExtensions.GetSolutionFileName()).Directory.FullName;
                PaketLauncher.LaunchPaket(dir, "init",
                                          (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
                dependenciesFile = Dependencies.Locate(selectedFileName);
            }

            var secondWindow = new AddPackage();

            //Create observable paket trace
            var paketTraceObs = Observable.Create <Logging.Trace>(observer =>
            {
                [email protected](x => observer.OnNext(x));
                return(Disposable.Create(() =>
                {
                }));
            });

            Action <NugetResult> addPackageToDependencies = result =>
            {
                if (projectGuid != null)
                {
                    var guid = Guid.Parse(projectGuid);
                    DteHelper.ExecuteCommand("File.SaveAll");
                    SolutionExplorerExtensions.UnloadProject(guid);
                    PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "add " + result.PackageName + " --project " + selectedFileName,
                                              (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
                    SolutionExplorerExtensions.ReloadProject(guid);
                }
                else
                {
                    PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "add " + result.PackageName,
                                              (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
                }
            };

            Func <string, IObservable <string> > searchNuGet =
                searchText => Observable.Create <string>(obs =>
            {
                var disposable = new CancellationDisposable();

                dependenciesFile
                .SearchPackagesByName(
                    searchText,
                    FSharpOption <CancellationToken> .Some(disposable.Token),
                    FSharpOption <int> .None)
                .Subscribe(obs);

                return(disposable);
            });

            //TODO: Use interfaces?
            secondWindow.ViewModel = new AddPackageViewModel(searchNuGet, addPackageToDependencies, paketTraceObs);
            secondWindow.ShowDialog();
        }