Exemplo n.º 1
0
        private void ResolveActiveProjectsReferencesInternal(ResolveReferencesCommandModel selectedCommandModel)
        {
            this.Worker.ReportProgress(0, this.Info.OnStartResolving);

            EnvDTE.DTE instanceService = this.package.GetDteService();
            Dictionary <string, ReferenceModel> availableReplaceReferences = this.GetAvailableReplaceReferences(selectedCommandModel);
            Dictionary <string, ReferenceModel> referencesThanMustBeAdded  = this.GetReferencesThatMustBeAdded(selectedCommandModel);

            try
            {
                foreach (EnvDTE.Project projectItem in (IEnumerable)instanceService.DTE.ActiveSolutionProjects)
                {
                    VSLangProj.VSProject project = (projectItem.Object as VSLangProj.VSProject);

                    if (project != null)
                    {
                        this.ResolveProjectReferences(project, availableReplaceReferences, referencesThanMustBeAdded);
                    }
                }
            }
            catch (Exception ex)
            {
                this.Worker.ReportProgress(50, GetAction(() => { this.Info.DoOnException(ex); }));
            }

            this.Worker.ReportProgress(100, this.Info.OnFinishedResolving);
        }
Exemplo n.º 2
0
        private void SaveChanges()
        {
            string text = "Settings successfully saved!";

            try
            {
                int index;

                if (this.TryGetSelectedCommandIndex(out index))
                {
                    ResolveReferencesCommandModel model = this.SelectedCommandViewModel.ToModel();
                    this.ResolveReferencesCommands.RemoveAt(index);
                    this.ResolveReferencesCommands.Insert(index, model);
                    this.SelectedCommandIndex = index;

                    this.Package.SaveUserSettings(new UserSettingsModel()
                    {
                        SelectedIndex = index,
                        CommandModels = this.ResolveReferencesCommands.ToArray()
                    });
                }
            }
            catch (Exception ex)
            {
                text = string.Format("Some error occured: {0} \n StackTrace: {1}", ex.Message, ex.StackTrace);
            }

            System.Windows.MessageBox.Show(text, "Settings save result");
        }
Exemplo n.º 3
0
        private void CreateCommandAction()
        {
            ResolveReferencesCommandModel model = new ResolveReferencesCommandModel("Unnamed command", Enumerable.Empty <ReplaceReferencesOptionModel>(), Enumerable.Empty <ReferenceModel>());

            this.ResolveReferencesCommands.Add(model);
            this.SelectedCommandIndex = this.ResolveReferencesCommands.Count - 1;
        }
Exemplo n.º 4
0
 public void ResolveSingleProjectReferences(VSLangProj.VSProject project, ResolveReferencesCommandModel selectedCommandModel)
 {
     if (!this.Worker.IsBusy)
     {
         this.AttachToWorkerEventsWhenResolvingSingleProject();
         this.Worker.RunWorkerAsync(new Tuple <VSLangProj.VSProject, ResolveReferencesCommandModel>(project, selectedCommandModel));
     }
 }
Exemplo n.º 5
0
 public void ResolveActiveProjectsReferences(ResolveReferencesCommandModel selectedCommandModel)
 {
     if (!this.Worker.IsBusy)
     {
         this.AttachToWorkerEventsWhenResolvingActiveProjects();
         this.Worker.RunWorkerAsync(selectedCommandModel);
     }
 }
Exemplo n.º 6
0
 public void ResolveActiveProjectsReferences(ResolveReferencesCommandModel selectedCommandModel)
 {
     if (this.EnsureNotResolving())
     {
         ReferenceResolver resolver = this.PrepareReferenceResolverWithDialog();
         resolver.ResolveActiveProjectsReferences(selectedCommandModel);
     }
 }
Exemplo n.º 7
0
        private void Worker_DoWorkWhenResolvingSingleProject(object sender, DoWorkEventArgs e)
        {
            var arguments = (Tuple <VSLangProj.VSProject, ResolveReferencesCommandModel>)e.Argument;

            VSLangProj.VSProject          project = arguments.Item1;
            ResolveReferencesCommandModel selectedCommandModel = arguments.Item2;

            this.ResolveSingleProjectReferencesInternal(project, selectedCommandModel);
        }
Exemplo n.º 8
0
        private void ExecuteCommandAction()
        {
            int index;

            if (this.TryGetSelectedCommandIndex(out index))
            {
                ResolveReferencesCommandModel command = this.SelectedCommandViewModel.ToModel();
                this.Package.ResolveActiveProjectsReferences(command);
            }
        }
Exemplo n.º 9
0
        public ResolveReferencesCommandModel GetSelectedCommandModel()
        {
            UserSettingsModel             settings      = this.GetUserSettings();
            ResolveReferencesCommandModel selectedModel = null;

            if (settings.SelectedIndex > -1)
            {
                selectedModel = settings.CommandModels[settings.SelectedIndex];
            }

            return(selectedModel);
        }
Exemplo n.º 10
0
        private Dictionary <string, ReferenceModel> GetReferencesThatMustBeAdded(ResolveReferencesCommandModel selectedCommandModel)
        {
            Dictionary <string, ReferenceModel> referencesToAdd = new Dictionary <string, ReferenceModel>();

            foreach (ReferenceModel model in selectedCommandModel.ReferencesToResolve)
            {
                if (File.Exists(model.Path))
                {
                    referencesToAdd[model.Name] = model;
                }
            }

            return(referencesToAdd);
        }
Exemplo n.º 11
0
        // This method is never used and tested!
        public void ResolveSelectedProjectReferences(ResolveReferencesCommandModel selectedCommandModel)
        {
            if (this.EnsureNotResolving())
            {
                object selectedObject = this.GetSelectedContextMenuItem();

                VSLangProj.VSProject project = selectedObject as VSLangProj.VSProject;

                if (project != null)
                {
                    ReferenceResolver resolver = this.PrepareReferenceResolverWithDialog();
                    resolver.ResolveSingleProjectReferences(project, selectedCommandModel);
                }
            }
        }
Exemplo n.º 12
0
        public void LoadModel(ResolveReferencesCommandModel model)
        {
            this.CommandName = model.CommandName;

            this.ReferencesToReplace.Clear();
            foreach (ReplaceReferencesOptionModel optionModel in model.ReferencesToReplace)
            {
                this.ReferencesToReplace.Add(optionModel);
            }

            this.ReferencesToResolve.Clear();
            foreach (ReferenceModel reference in model.ReferencesToResolve)
            {
                this.ReferencesToResolve.Add(reference);
            }
        }
Exemplo n.º 13
0
        private Dictionary <string, ReferenceModel> GetAvailableReplaceReferences(ResolveReferencesCommandModel selectedCommandModel)
        {
            Dictionary <string, ReferenceModel> availableReferences = new Dictionary <string, ReferenceModel>();

            foreach (ReplaceReferencesOptionModel replaceModel in selectedCommandModel.ReferencesToReplace)
            {
                if (Directory.Exists(replaceModel.CopyFolderPath))
                {
                    string[] files = Directory.GetFiles(replaceModel.CopyFolderPath, "*.dll", SearchOption.TopDirectoryOnly);

                    foreach (string filePath in files)
                    {
                        string shortFileName = Path.GetFileNameWithoutExtension(filePath);

                        //if (Regex.IsMatch(shortFileName, replaceModel.ReferenceToReplaceRegexPattern))
                        //{
                        availableReferences[shortFileName] = new ReferenceModel(shortFileName, filePath);
                        //}
                    }
                }
            }

            return(availableReferences);
        }
Exemplo n.º 14
0
        private void Worker_DoWorkWhenResolvingActiveProjects(object sender, DoWorkEventArgs e)
        {
            ResolveReferencesCommandModel selectedCommandModel = (ResolveReferencesCommandModel)e.Argument;

            this.ResolveActiveProjectsReferencesInternal(selectedCommandModel);
        }
Exemplo n.º 15
0
        private void ResolveSingleProjectReferencesInternal(VSLangProj.VSProject project, ResolveReferencesCommandModel selectedCommandModel)
        {
            this.Worker.ReportProgress(0, this.Info.OnStartResolving);

            Dictionary <string, ReferenceModel> availableReplaceReferences = this.GetAvailableReplaceReferences(selectedCommandModel);
            Dictionary <string, ReferenceModel> referencesThanMustBeAdded  = this.GetReferencesThatMustBeAdded(selectedCommandModel);

            try
            {
                this.ResolveProjectReferences(project, availableReplaceReferences, referencesThanMustBeAdded);
            }
            catch (Exception ex)
            {
                this.Worker.ReportProgress(50, GetAction(() => { this.Info.DoOnException(ex); }));
            }

            this.Worker.ReportProgress(100, this.Info.OnFinishedResolving);
        }