Ejemplo n.º 1
0
        private void Refresh()
        {
            //Because refreshing removes all components, we need to store the current selection,
            // so we can correctly reset it once the files are imported from the repository.

            HandleVbeSinkEvents = false;

            var codePane = Project.VBE.ActiveCodePane;

            if (codePane != null)
            {
                var codePaneWrapper = _wrapperFactory.Create(codePane);
                var selection       = new QualifiedSelection(new QualifiedModuleName(codePaneWrapper.CodeModule.Parent),
                                                             codePaneWrapper.Selection);
                string name = null;
                if (selection.QualifiedName.Component != null)
                {
                    name = selection.QualifiedName.Component.Name;
                }

                try
                {
                    Project.LoadAllComponents(CurrentRepository.LocalLocation);
                }
                catch (AggregateException ex)
                {
                    HandleVbeSinkEvents = true;
                    throw new SourceControlException("Unknown exception.", ex);
                }

                Project.VBE.SetSelection(selection.QualifiedName.Project, selection.Selection, name, _wrapperFactory);
            }
            else
            {
                try
                {
                    Project.LoadAllComponents(CurrentRepository.LocalLocation);
                }
                catch (AggregateException ex)
                {
                    HandleVbeSinkEvents = true;
                    throw new SourceControlException("Unknown exception.", ex);
                }
            }

            HandleVbeSinkEvents = true;
        }