Пример #1
0
        public override void Run(DTE2 app)
        {
            try
            {
                var currentSelectedFilepath = GetSourceFilePath(app) ?? "";

                var basePathsList = Utils.FindSolutionDirectories(app).ToList();

                if (!basePathsList.Any())
                {
                    return;
                }

                var basePath = basePathsList.FirstOrDefault(p => currentSelectedFilepath.StartsWith(p, StringComparison.OrdinalIgnoreCase)) ??
                               basePathsList.FirstOrDefault(p => p.EndsWith($"{currentSelectedFilepath}\\".Replace("#", null), StringComparison.OrdinalIgnoreCase));

                if (basePath.HasValue())
                {
                    basePathsList.Remove(basePath);
                    basePathsList.Insert(0, basePath);
                }

                var basePaths  = basePathsList.ToArray();
                var repository = new Repository(/*basePath*/);
                var loader     = GetLoaderAgent(basePaths, repository);
                var filterer   = new Filterer(basePaths, repository);
                var form       = new FinderForm(GetTitle(),
                                                GetColor(),
                                                loader,
                                                filterer,
                                                defaultSearchTerm: app.GetSelectedText());

                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var foundItem = form.GetSelectedItem();
                    FoundItemsBank.Items = filterer.FoundItems;
                    GotoItem(app, basePaths, foundItem);
                }

                else
                {
                    app.StatusBar.Text = "Ready ...";
                }
            }
            catch (Exception e)
            {
                ErrorNotification.EmailError(e);
            }
        }
        public override void Run(DTE2 app)
        {
            try
            {
                var basePaths = Utils.FindSolutionDirectories(app);

                if (basePaths == null || basePaths.Count() == 0)
                {
                    return;
                }

                var repository = new Repository(/*basePath*/);
                var loader     = GetLoaderAgent(basePaths, repository);
                var filterer   = new Filterer(basePaths, repository);
                var form       = new FinderForm(GetTitle(), GetColor(), loader, filterer, defaultSearchTerm: app.GetSelectedText());

                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var foundItem = form.GetSelectedItem();
                    FoundItemsBank.Items = filterer.FoundItems;
                    GotoItem(app, basePaths, foundItem);
                }

                else
                {
                    app.StatusBar.Text = "Ready";
                }
            }
            catch (Exception e) { ErrorNotification.EmailError(e); }
        }