private void EnsureValidProjectId(IVBProject project) { if (string.IsNullOrEmpty(project.ProjectId) || _projects.Keys.Contains(project.ProjectId)) { project.AssignProjectId(); } }
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)); }
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; }
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); }
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; }