private bool TryGetEnvironmentAndView() { TextView = AdaptersFactoryService.GetWpfTextView(TextViewAdapter); try { VsEnvironment = (DTE)ServiceProvider.GetService(typeof(DTE)); if (VsEnvironment != null) ProjectExplorer = new ProjectExplorer(VsEnvironment); } catch (COMException ex) { //TODO: Log the COM Exception somewhere //Unable to attach to the current visual studio environment VsEnvironment = null; } return TextView != null && VsEnvironment != null; }
private IProjectExplorer GetFromVsEnvironment() { IProjectExplorer projectExplorer = null; try { VsEnvironment = (DTE)ServiceProvider.GetService(typeof(DTE)); if (VsEnvironment != null) projectExplorer = new ProjectExplorer(VsEnvironment); } catch (COMException ex) { //TODO: Log the COM Exception somewhere //Unable to attach to the current visual studio environment VsEnvironment = null; } return projectExplorer; }