本文整理汇总了C#中IVsSolution.AdviseSolutionEvents方法的典型用法代码示例。如果您正苦于以下问题:C# IVsSolution.AdviseSolutionEvents方法的具体用法?C# IVsSolution.AdviseSolutionEvents怎么用?C# IVsSolution.AdviseSolutionEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVsSolution
的用法示例。
在下文中一共展示了IVsSolution.AdviseSolutionEvents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisualStudioProjectTracker
public VisualStudioProjectTracker(IServiceProvider serviceProvider)
{
_projectMap = new Dictionary<ProjectId, AbstractProject>();
_projectPathToIdMap = new Dictionary<string, ProjectId>(StringComparer.OrdinalIgnoreCase);
_serviceProvider = serviceProvider;
_workspaceHosts = new List<WorkspaceHostState>(capacity: 1);
_vsSolution = (IVsSolution)serviceProvider.GetService(typeof(SVsSolution));
_runningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable));
uint solutionEventsCookie;
_vsSolution.AdviseSolutionEvents(this, out solutionEventsCookie);
_solutionEventsCookie = solutionEventsCookie;
// It's possible that we're loading after the solution has already fully loaded, so see if we missed the event
var shellMonitorSelection = (IVsMonitorSelection)serviceProvider.GetService(typeof(SVsShellMonitorSelection));
uint fullyLoadedContextCookie;
if (ErrorHandler.Succeeded(shellMonitorSelection.GetCmdUIContextCookie(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_guid, out fullyLoadedContextCookie)))
{
int fActive;
if (ErrorHandler.Succeeded(shellMonitorSelection.IsCmdUIContextActive(fullyLoadedContextCookie, out fActive)) && fActive != 0)
{
_solutionLoadComplete = true;
}
}
}
示例2: LocatorWindowCommand
/// <summary>
/// Initializes a new instance of the <see cref="LocatorWindowCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
private LocatorWindowCommand(Package package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.package = package;
OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.ShowToolWindow, menuCommandID);
commandService.AddCommand(menuItem);
}
// Get the instance number 0 of this tool window. This window is single instance so this instance
// is actually the only one.
// The last flag is set to true so that if the tool window does not exists it will be created.
_locatorWindow = package.FindToolWindow(typeof(LocatorWindow), 0, true) as LocatorWindow;
if ((null == _locatorWindow) || (null == _locatorWindow.Frame))
{
throw new NotSupportedException("Cannot create tool window");
}
_locator = new Locator();
_solution = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
_solution.AdviseSolutionEvents(_locator, out _cookie);
_locatorWindow.SetLocator(_locator);
_locator.StartWorkerThread();
}
示例3: SolutionChangeEventListener
/// <summary>
/// Constructor.
/// Register Solution events.
/// </summary>
public SolutionChangeEventListener() {
InitNullEvents();
solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
if(solution != null) {
solution.AdviseSolutionEvents(this, out solutionEventsCookie);
}
}
示例4: SolutionEventsListener
public SolutionEventsListener(IServiceProvider serviceProvider)
{
solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
if (solution != null)
{
solution.AdviseSolutionEvents(this, out solutionEventsCookie);
}
}
示例5: SolutionEventSinks
public SolutionEventSinks()
{
solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution));
if (null == solution)
Trace.WriteLine("Can't access solution service");
else
solution.AdviseSolutionEvents((IVsSolutionEvents)this, out solutionEventsCookie);
}
示例6: AdviceSolutionEvents
private void AdviceSolutionEvents()
{
solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
if (solution != null)
{
ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out solutionCookie));
}
}
示例7: SolutionEventListener
public SolutionEventListener([Import(typeof (SVsServiceProvider))] IServiceProvider serviceProvider)
{
ValidateArg.NotNull(serviceProvider, "serviceProvider");
_solution = (IVsSolution) serviceProvider.GetService(typeof (IVsSolution));
if (_solution != null)
{
_solution.AdviseSolutionEvents(this, out _solutionEventsCookie);
}
}
示例8: SolutionEvent
public SolutionEvent(ServiceProvider sp)
{
serviceProvider = sp;
solution = (IVsSolution)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(IVsSolution));
dte = (EnvDTE.DTE)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(EnvDTE.DTE));
//serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
if (solution != null)
{
solution.AdviseSolutionEvents(this, out solutionEventsCookie);
}
}
示例9: XamlTextViewCreationListener
public XamlTextViewCreationListener(
[Import(typeof(SVsServiceProvider))] System.IServiceProvider services,
ICommandHandlerServiceFactory commandHandlerServiceFactory,
IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
IXamlDocumentAnalyzerService analyzerService,
VisualStudioWorkspaceImpl vsWorkspace)
{
_serviceProvider = services;
_commandHandlerService = commandHandlerServiceFactory;
_editorAdaptersFactory = editorAdaptersFactoryService;
_vsWorkspace = vsWorkspace;
_rdt = new Lazy<RunningDocumentTable>(() => new RunningDocumentTable(_serviceProvider));
_vsSolution = (IVsSolution)_serviceProvider.GetService(typeof(SVsSolution));
AnalyzerService = analyzerService;
uint solutionEventsCookie;
if (ErrorHandler.Succeeded(_vsSolution.AdviseSolutionEvents(this, out solutionEventsCookie)))
{
_solutionEventsCookie = solutionEventsCookie;
}
}
示例10: SolutionService
public SolutionService(IServiceProvider serviceProvider, SourceControlProvider sourceControlProvider)
{
_serviceProvider = serviceProvider;
_vsSolution = serviceProvider.GetService<SVsSolution, IVsSolution>();
_isRefreshEnabled = true;
sourceControlProvider.Activated += (sender, e) =>
{
string directory, fileName, userFile;
_vsSolution.GetSolutionInfo(out directory, out fileName, out userFile);
_vsSolution.AdviseSolutionEvents(this, out _cookieSolutionEvents);
if (string.IsNullOrEmpty(directory))
_repositoryService.CloseRepository();
else
_repositoryService.OpenRepositoryAt(directory);
};
sourceControlProvider.Deactivated += (sender, e) =>
{
StopListeningToSolutionEvents();
_repositoryService.CloseRepository();
};
}
示例11: Initialize
protected override void Initialize()
{
Trace.WriteLine(String.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));
base.Initialize();
try
{
errorList = new VSTools.ErrorList.Pane(this);
Log._.Received -= onLogReceived;
Log._.Received += onLogReceived;
OleMenuCommandService mcs = (OleMenuCommandService)GetService(typeof(IMenuCommandService));
// Top Menu
_menuItemMain = new MenuCommand(_menuMainCallback, new CommandID(GuidList.CMD_MAIN, PkgCmdIDList.CMD_MAIN));
_menuItemMain.Visible = false;
mcs.AddCommand(_menuItemMain);
mcs.AddCommand(
new MenuCommand(
_menuCfgUnwarnCallback,
new CommandID(GuidList.CMD_MAIN, PkgCmdIDList.CMD_UNWARN)
)
);
// To listen events that fired as a IVsSolutionEvents
spSolution = (IVsSolution)ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution));
spSolution.AdviseSolutionEvents(this, out _pdwCookieSolution);
initAppEvents();
}
catch(Exception ex)
{
string msg = string.Format("{0}\n{1}\n\n-----\n{2}",
"Something went wrong -_-",
"Try to restart IDE or reinstall current plugin in Extension Manager.",
ex.ToString());
Debug.WriteLine(msg);
int res;
Guid id = Guid.Empty;
IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
uiShell.ShowMessageBox(
0,
ref id,
"Initialize vsCommandEvent",
msg,
string.Empty,
0,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
OLEMSGICON.OLEMSGICON_WARNING,
0,
out res));
}
}
示例12: AdviseSolutionEvents
partial void AdviseSolutionEvents()
{
solution = (IVsSolution)GetService(typeof(SVsSolution));
solution.AdviseSolutionEvents(this, out solutionEventsCookie);
}
示例13: Initialize
protected override void Initialize()
{
base.Initialize();
AddMenuCommands();
_solution = GetService(typeof (SVsSolution)) as IVsSolution;
if (_solution != null)
_solution.AdviseSolutionEvents(this, out _dwCookie);
var dte = (DTE)GetService(typeof(DTE));
var itemOperations = new ItemOperationsWrapper(dte);
var solutionFolderWrapper = new SolutionFolderWrapper(dte);
var defaultDocumentPolicy = new DefaultDocumentPolicy();
var server = new WebServer();
_impl = new WelcomePageImpl(solutionFolderWrapper, defaultDocumentPolicy, itemOperations, server);
}
示例14: Initialize
/////////////////////////////////////////////////////////////////////////////
// Overridden Package Implementation
/// <summary>
/// Initialization of the package; this method is called right after the package is sited, so this is the place
/// where you can put all the initialization code that rely on services provided by VisualStudio.
/// </summary>
protected override void Initialize()
{
Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
base.Initialize();
// listen for solution events
_solution = (IVsSolution)GetService(typeof(SVsSolution));
ErrorHandler.ThrowOnFailure(_solution.AdviseSolutionEvents(this, out _solutionCookie));
_dte = (DTE)GetService(typeof(SDTE));
var events = _dte.Events;
_buildEvents = events.BuildEvents;
if (_errorListProvider == null)
_errorListProvider = new ErrorListProvider(this);
Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
{
Options = (ShowMissingOptions)GetDialogPage(typeof(ShowMissingOptions));
}), DispatcherPriority.ApplicationIdle, null);
_buildEvents.OnBuildProjConfigBegin += BuildEventsOnOnBuildProjConfigBegin;
_buildEvents.OnBuildBegin += BuildEventsOnOnBuildBegin;
_buildEvents.OnBuildDone += BuildEventsOnOnBuildDone;
}
示例15: AzureSolutionListener
public AzureSolutionListener(IServiceProvider serviceProvider) {
_serviceProvider = serviceProvider;
_solution = _serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
ErrorHandler.ThrowOnFailure(_solution.AdviseSolutionEvents(this, out _eventsCookie));
}