internal void InitProjectInfos(SVsServiceProvider provider, ABnfFactory factory) { if (factory == null) { return; } if (m_server != null) { return; } m_server = new ALanguageServer(); m_server.Start(factory); if (m_cookie != 0) { return; } if (m_solution != null) { return; } m_solution = provider.GetService(typeof(SVsSolution)) as IVsSolution; if (m_solution == null) { return; } m_dot_ext = factory.GetDotExt(); m_file_icon = factory.GetFileIcon(); // 读取所有工程 m_projects.Clear(); Guid rguidEnumOnlyThisType = new Guid(); IEnumHierarchies ppenum = null; m_solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum); IVsHierarchy[] rgelt = new IVsHierarchy[1]; uint pceltFetched = 0; while (ppenum.Next(1, rgelt, out pceltFetched) == VSConstants.S_OK && pceltFetched == 1) { IVsSccProject2 sccProject2 = rgelt[0] as IVsSccProject2; if (sccProject2 != null) { string project_path = GetProjectPath(rgelt[0]); if (project_path != null) { if (m_server != null) { m_server.AddTask(() => m_server.AddProjectInfo(project_path)); } m_projects[rgelt[0]] = new UIProjectInfo(this, rgelt[0], project_path, m_dot_ext, m_file_icon); } } } // 监听工程变化 m_solution.AdviseSolutionEvents(this, out m_cookie); }
public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded) { string project_path = GetProjectPath(pHierarchy); if (project_path == null) { return(0); } if (m_server != null) { m_server.AddTask(() => m_server.AddProjectInfo(project_path)); } m_projects[pHierarchy] = new UIProjectInfo(this, pHierarchy, project_path, m_dot_ext, m_file_icon); return(0); }