コード例 #1
0
 private void EnsureValidProjectId(IVBProject project)
 {
     if (string.IsNullOrEmpty(project.ProjectId) || _projects.Keys.Contains(project.ProjectId))
     {
         project.AssignProjectId();
     }
 }
コード例 #2
0
        private string GetReferenceProjectId(IReference reference, IReadOnlyList <IVBProject> projects)
        {
            IVBProject project = null;

            foreach (var item in projects)
            {
                try
                {
                    // check the name not just the path, because path is empty in tests:
                    if (item.Name == reference.Name && item.FileName == reference.FullPath)
                    {
                        project = item;
                        break;
                    }
                }
                catch (IOException)
                {
                    // Filename throws exception if unsaved.
                }
                catch (COMException e)
                {
                    Logger.Warn(e);
                }
            }

            if (project != null)
            {
                if (string.IsNullOrEmpty(project.ProjectId))
                {
                    project.AssignProjectId();
                }
                return(project.ProjectId);
            }
            return(QualifiedModuleName.GetProjectId(reference));
        }
コード例 #3
0
        private void RegisterProjectHandlers(IVBProject project)
        {
            if (project.IsWrappingNullReference || project.Protection != ProjectProtection.Unprotected)
            {
                return;
            }

            project.AssignProjectId();

            var components = project.VBComponents;

            _components.Add(project.ProjectId, components);

            components.AttachEvents();
            components.ComponentAdded     += ComponentAddedHandler;
            components.ComponentRemoved   += ComponentRemovedHandler;
            components.ComponentRenamed   += ComponentRenamedHandler;
            components.ComponentActivated += ComponentActivatedHandler;
            components.ComponentSelected  += ComponentSelectedHandler;
            components.ComponentReloaded  += ComponentReloadedHandler;

            var references = project.References;

            _references.Add(project.ProjectId, references);
            references.AttachEvents();
            references.ItemAdded   += ProjectReferenceAddedHandler;
            references.ItemRemoved += ProjectReferenceRemovedHandler;
        }
コード例 #4
0
        public static string GetProjectId(IVBProject project)
        {
            if (project.IsWrappingNullReference)
            {
                return(string.Empty);
            }

            var projectId = project.ProjectId;

            if (string.IsNullOrEmpty(projectId))
            {
                project.AssignProjectId();
                projectId = project.ProjectId;
            }

            return(projectId);
        }
コード例 #5
0
ファイル: VbeEvents.cs プロジェクト: xxxmen/Rubberduck
        private void RegisterComponents(IVBProject project)
        {
            if (project.IsWrappingNullReference || project.Protection != ProjectProtection.Unprotected)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(project.ProjectId))
            {
                project.AssignProjectId();
            }

            var components = project.VBComponents;

            _components.Add(project.ProjectId, components);

            components.AttachEvents();
            components.ComponentAdded     += ComponentAddedHandler;
            components.ComponentRemoved   += ComponentRemovedHandler;
            components.ComponentRenamed   += ComponentRenamedHandler;
            components.ComponentActivated += ComponentActivatedHandler;
            components.ComponentSelected  += ComponentSelectedHandler;
            components.ComponentReloaded  += ComponentReloadedHandler;
        }