protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress); // NOTE: this switch is already performed within the base.InitializeAsync() method. await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); _CurrentSolutionRcsType = RcsType.Unknown; //EnvDTE.IVsExtensibility extensibility = await GetServiceAsync(typeof(EnvDTE.IVsExtensibility)) as EnvDTE.IVsExtensibility; //_DTE2 = (DTE2)extensibility.GetGlobalsObject(null).DTE as EnvDTE80.DTE2; _DTE2 = Package.GetGlobalService(typeof(DTE)) as DTE2; IVsSolution solution = await GetServiceAsync(typeof(SVsSolution)) as IVsSolution; Assumes.Present(solution); int hr; uint pdwCookie; hr = solution.AdviseSolutionEvents(this, out pdwCookie); Marshal.ThrowExceptionForHR(hr); _VsShell = await GetServiceAsync(typeof(SVsShell)) as IVsShell; _VsRegisterScciProvider = await GetServiceAsync(typeof(IVsRegisterScciProvider)) as IVsRegisterScciProvider; _VsGetScciProviderInterface = await GetServiceAsync(typeof(IVsRegisterScciProvider)) as IVsGetScciProviderInterface; _SettingsStore = GetWritableSettingsStore(); TaskManager.Initialize(this); solutionEvents = ((Events2)_DTE2.Events).SolutionEvents; solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(this.SolutionEvents_Opened); SolutionEvents_Opened(); }
private static IntPtr GetInterface(this IVsGetScciProviderInterface getScciProvider, Guid guid) { IntPtr pvv; getScciProvider.GetSourceControlProviderInterface(ref guid, out pvv); return(pvv); }
/// <summary> /// Initializes static services of the command. /// Adds our command handlers for menu (commands must exist in the command table file). /// </summary> /// <param name="package">Owner package, not null.</param> public static async System.Threading.Tasks.Task InitializeAsync(AsyncPackage package, System.Threading.CancellationToken cancellationToken) { await package.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken : cancellationToken); scciProvider = await package.GetServiceAsync(typeof(IVsRegisterScciProvider)) as IVsGetScciProviderInterface; var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; if (commandService != null) { AddMenuCommand(commandService, CmdID_SavedHeadSolution, SavedHeadSolutionCallback, SavedHeadSolutionQuery); AddMenuCommand(commandService, CmdID_WorkingHeadSolution, WorkingHeadSolutionCallback, WorkingHeadSolutionQuery); AddMenuCommand(commandService, CmdID_SavedHeadCodeWin, SavedHeadCodeWinCallback, SavedHeadCodeWinQuery); AddMenuCommand(commandService, CmdID_WorkingHeadCodeWin, WorkingHeadCodeWinCallback, WorkingHeadCodeWinQuery); AddMenuCommand(commandService, CmdID_SavedHeadSourceChanges, SavedHeadSolutionCallback, null); } teamExplorer = await package.GetServiceAsync(typeof(ITeamExplorer)) as ITeamExplorer; dte = Package.GetGlobalService(typeof(DTE)) as EnvDTE80.DTE2; }
public static IVsSccProvider GetProvider(this IVsGetScciProviderInterface getScciProvider) { IVsSccProvider provider = null; IntPtr pUnk = IntPtr.Zero; try { pUnk = getScciProvider.GetInterface(typeof(IVsSccProvider).GUID); if (pUnk != IntPtr.Zero) { provider = Marshal.GetObjectForIUnknown(pUnk) as IVsSccProvider; } } finally { if (pUnk != IntPtr.Zero) { Marshal.Release(pUnk); } } return(provider); }