示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebViewControl"/> class.
        /// </summary>
        public WebViewControl()
        {
            try {
                using (Log.CriticalOperation($"ctor", Serilog.Events.LogEventLevel.Debug)) {
                    this.IsVisibleChanged += WebViewControl_IsVisibleChanged;

                    InitializeComponent();

                    _componentModel = Package.GetGlobalService(typeof(SComponentModel)) as IComponentModel;
                    Assumes.Present(_componentModel);

                    _eventAggregator = _componentModel.GetService <IEventAggregator>();
                    _sessionService  = _componentModel.GetService <ISessionService>();
                    _browserService  = _componentModel.GetService <IBrowserService>();

                    _browserService.Initialize();
                    _browserService.AttachControl(Grid);
                    _browserService.LoadSplashView();

                    _languageServerDisconnectedEvent = _eventAggregator?.GetEvent <LanguageServerDisconnectedEvent>()
                                                       .Subscribe(_ => {
                        Log.Debug($"{nameof(LanguageServerDisconnectedEvent)} IsReloading={_?.IsReloading}");

                        // if we're in the process of reloading the agent, don't show the splash screen
                        if (_.IsReloading)
                        {
                            return;
                        }

                        _browserService.LoadSplashView();
                    });

                    SetupInitialization();
                }
            }
            catch (Exception ex) {
                Log.Fatal(ex.UnwrapCompositionException(), nameof(WebViewControl));
            }
        }