Пример #1
0
        object CreateService(IServiceContainer container, Type serviceType)
        {
            _taskContext.ThrowIfNotOnMainThread();

            if (typeof(YetiVSIService) == serviceType)
            {
                var options = GetDialogPage(typeof(OptionPageGrid)) as OptionPageGrid;
                var yeti = new YetiVSIService(options);
                yeti.DebuggerOptions.ValueChanged += OnDebuggerOptionChanged;
                return yeti;
            }

            if (typeof(SLLDBShell) == serviceType)
            {
                var writer = new CommandWindowWriter(_taskContext,
                                                     (IVsCommandWindow) GetService(
                                                         typeof(SVsCommandWindow)));
                return new LLDBShell.LLDBShell(_taskContext, writer);
            }

            if (typeof(SMetrics) == serviceType)
            {
                return new MetricsService(_taskContext,
                                          Versions.Populate(
                                              (GetService(typeof(EnvDTE.DTE)) as EnvDTE._DTE)
                                              ?.RegistryRoot));
            }

            if (typeof(SDebugEngineManager) == serviceType)
            {
                return new DebugEngineManager();
            }

            if (typeof(SSessionNotifier) == serviceType)
            {
                ISessionNotifier sessionNotifier = new SessionNotifierService();
                var vsiService = (YetiVSIService) GetGlobalService(typeof(YetiVSIService));
                var exceptionRecorder =
                    new ExceptionRecorder((IMetrics) GetService(typeof(SMetrics)));
                var loadSymbolsCommand = new LoadSymbolsCommand(
                    _taskContext, this, exceptionRecorder, vsiService);
                sessionNotifier.SessionLaunched += loadSymbolsCommand.OnSessionLaunched;
                sessionNotifier.SessionStopped += loadSymbolsCommand.OnSessionStopped;

                var noSourceWindowHider = new NoSourceWindowHider(_taskContext, this,
                                                                  exceptionRecorder, vsiService);
                sessionNotifier.SessionLaunched += noSourceWindowHider.OnSessionLaunched;
                sessionNotifier.SessionStopped += noSourceWindowHider.OnSessionStopped;

                return sessionNotifier;
            }

            return null;
        }
        public void TestEventHandlerIsInvokedWhenStopNotificationSent()
        {
            ISessionNotifier notifier = new SessionNotifierService();

            bool invoked = false;

            notifier.SessionStopped += (sender, args) => invoked = true;

            notifier.NotifySessionStopped(new SessionStoppedEventArgs(null));

            Assert.IsTrue(invoked);
        }