当前位置: 首页>>代码示例>>C#>>正文


C# IVsSolution.AdviseSolutionEvents方法代码示例

本文整理汇总了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;
                }
            }
        }
开发者ID:nemec,项目名称:roslyn,代码行数:28,代码来源:VisualStudioProjectTracker.cs

示例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();
        }
开发者ID:SoulForMachine,项目名称:QtCreatorPack,代码行数:37,代码来源:LocatorWindowCommand.cs

示例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);
            }
        }
开发者ID:nkcsgexi,项目名称:SrcML.NET,代码行数:12,代码来源:SolutionReloadEventListener.cs

示例4: SolutionEventsListener

 public SolutionEventsListener(IServiceProvider serviceProvider)
 {
     solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
     if (solution != null)
     {
         solution.AdviseSolutionEvents(this, out solutionEventsCookie);
     }
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:8,代码来源:SolutionEventsListener.cs

示例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);
 }
开发者ID:jijo-paulose,项目名称:bistro-framework,代码行数:8,代码来源:ISolutionEvents.cs

示例6: AdviceSolutionEvents

 private void AdviceSolutionEvents()
 {
     solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
     if (solution != null)
     {
         ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out solutionCookie));
     }
 }
开发者ID:FreeFrags,项目名称:Typewriter,代码行数:8,代码来源:SolutionMonitor.cs

示例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);
            }
        }
开发者ID:smkanadl,项目名称:CTestTestAdapter,代码行数:10,代码来源:SolutionEventListener.cs

示例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);
     }
 }
开发者ID:MagnusTiberius,项目名称:NugetVsPlugin,代码行数:11,代码来源:SolutionEvent.cs

示例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;
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:22,代码来源:XamlTextViewCreationListener.cs

示例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();
            };
        }
开发者ID:resnikb,项目名称:GitWorkflows,代码行数:24,代码来源:SolutionService.cs

示例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));
            }
        }
开发者ID:3F,项目名称:vsCommandEvent,代码行数:59,代码来源:vsCommandEventPackage.cs

示例12: AdviseSolutionEvents

partial         void AdviseSolutionEvents()
        {
            solution = (IVsSolution)GetService(typeof(SVsSolution));
            solution.AdviseSolutionEvents(this, out solutionEventsCookie);
        }
开发者ID:slamj1,项目名称:ServiceMatrix,代码行数:5,代码来源:VSPackage.AutoOpen.cs

示例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);
        }
开发者ID:rlipscombe,项目名称:vs-welcome-page,代码行数:18,代码来源:WelcomePagePackage.cs

示例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;
        }
开发者ID:modulexcite,项目名称:VsShowMissing,代码行数:31,代码来源:Gardiner.VsShowMissingPackage.cs

示例15: AzureSolutionListener

 public AzureSolutionListener(IServiceProvider serviceProvider) {
     _serviceProvider = serviceProvider;
     _solution = _serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
     ErrorHandler.ThrowOnFailure(_solution.AdviseSolutionEvents(this, out _eventsCookie));
 }
开发者ID:lioaphy,项目名称:nodejstools,代码行数:5,代码来源:AzureSolutionListener.cs


注:本文中的IVsSolution.AdviseSolutionEvents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。