/// <summary>Initializes a new instance of the TeamExplorerIntegrator class, The constructor for the Add-in object. Place your initialization code within this method.</summary> public void Initialize(IVsExtensibility extensibility) { if (m_applicationObject != null) { throw new ApplicationException("TeamExplorerIntegrator already initialized"); } if (extensibility == null) { throw new ArgumentNullException(nameof(extensibility)); } // get IDE Globals object and DTE from that var dte2 = extensibility.GetGlobalsObject(null).DTE as DTE2; m_applicationObject = dte2; if (dte2 == null) { throw new ApplicationException("No DTE2"); } var tfsExt = (TeamFoundationServerExt)dte2.Application.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt"); m_srcCtrlExplorer = (VersionControlExt)dte2.Application.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt"); // var events = m_applicationObject.Events; DoConnect(tfsExt); }
protected override void Initialize() { base.Initialize(); _updateLock = new object(); IVsExtensibility extensibility = GetService <IVsExtensibility>(); _DTE2 = (DTE2)extensibility.GetGlobalsObject(null).DTE; _Version = GetVersion(_DTE2.Version); _Solution = GetService <SVsSolution>() as IVsSolution; IVsCfgProvider2 test = _Solution as IVsCfgProvider2; _SolutionEvents = new SolutionEvents(); int hr; uint pdwCookie; hr = _Solution.AdviseSolutionEvents(_SolutionEvents, out pdwCookie); Marshal.ThrowExceptionForHR(hr); _UpdateSolutionEvents = new UpdateSolutionEvents(); var vsSolutionBuildManager = GetService <SVsSolutionBuildManager>(); hr = (vsSolutionBuildManager as IVsSolutionBuildManager3).AdviseUpdateSolutionEvents3(_UpdateSolutionEvents, out pdwCookie); Marshal.ThrowExceptionForHR(hr); hr = (vsSolutionBuildManager as IVsSolutionBuildManager2).AdviseUpdateSolutionEvents(_UpdateSolutionEvents, out pdwCookie); Marshal.ThrowExceptionForHR(hr); if (VersionGreaterEqualTo(DTEVersion.VS15)) { LoadMef(); } }
/// <summary> /// Default constructor of the package. /// Inside this method you can place any initialization code that does not require /// any Visual Studio service because at this point the package object is created but /// not sited yet inside Visual Studio environment. The place to do all the other /// initialization is the Initialize method. /// </summary> public TfsProjectInfoPackage() { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString())); _extensibility = (IVsExtensibility)Package.GetGlobalService(typeof(IVsExtensibility)); _dte2 = (DTE2)_extensibility.GetGlobalsObject(null).DTE; _vcExt = _dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt; // The SolutionEvents is an *instance* variable that must be kept around for the events to work! _solutionEvents = _dte2.Events.SolutionEvents; _solutionEvents.Opened += () => ReadSolutionInfo(); _solutionEvents.AfterClosing += () => ReadSolutionInfo(); }
/// <summary> /// Default constructor of the package. /// Inside this method you can place any initialization code that does not require /// any Visual Studio service because at this point the package object is created but /// not sited yet inside Visual Studio environment. The place to do all the other /// initialization is the Initialize method. /// </summary> public TfsProjectInfoPackage() { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString())); _extensibility = (IVsExtensibility)Package.GetGlobalService(typeof(IVsExtensibility)); _dte2 = (DTE2)_extensibility.GetGlobalsObject(null).DTE; _vcExt = _dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt; // The SolutionEvents is an *instance* variable that must be kept around for the events to work! _solutionEvents = _dte2.Events.SolutionEvents; _solutionEvents.Opened += () => ReadSolutionInfo(); _solutionEvents.AfterClosing += () => ReadSolutionInfo(); }
protected override void Initialize() { base.Initialize(); _CurrentSolutionRcsType = RcsType.Unknown; IVsExtensibility extensibility = GetService <IVsExtensibility>(); _DTE2 = (DTE2)extensibility.GetGlobalsObject(null).DTE; IVsSolution solution = GetService <SVsSolution>() as IVsSolution; int hr; uint pdwCookie; hr = solution.AdviseSolutionEvents(this, out pdwCookie); Marshal.ThrowExceptionForHR(hr); _VsShell = GetService <SVsShell>() as IVsShell; _VsRegisterScciProvider = GetService <IVsRegisterScciProvider>(); _SettingsStore = GetWritableSettingsStore(); }