/// <summary>
        /// Registers a plugin, calling <see cref="IEditorPlugin.RegisterPlugin(IServiceRegistry)"/>.
        /// </summary>
        /// <param name="plugin"></param>
        public void Register(IEditorPlugin plugin)
        {
            if (activePlugins.ContainsKey(plugin.GetType()))
            {
                throw new InvalidOperationException($"Plugin of type '{plugin.GetType()}' is already registered.");
            }

            Logger.Debug($"Registering plugin '{plugin.GetType().FullName}'...");

            plugin.RegisterPlugin(Services);
            activePlugins.Add(plugin.GetType(), plugin);

            Logger.Info($"Registered plugin '{plugin.GetType().FullName}'.");
        }
        private void CreateAndUpdateView(object context)
        {
            var newView = ViewFactory(context);

            Logger.Debug("Updating UI container...");
            DebugCheckIfEqual(LastView, newView);
            newView.UpdateRoot(Container, LastView);

            Container.Tag = DateTime.Now; // save last update time

            LastView = newView;
            Logger.Debug($"UI updated. Last virtual view saved. Tagged: ({Container.Tag}).");

            Cleanup(context);
        }
        public async Task CloseTab(ITabViewModel tabViewModel)
        {
            Logger.Debug($"Close tab '{tabViewModel.Id}'.");

            var toolIdx   = toolTabs.IndexOf(tabViewModel);
            var editorIdx = editorTabs.IndexOf(tabViewModel);

            if (toolIdx >= 0)
            {
                toolTabs.Remove(tabViewModel);
                if (selectedToolTab == tabViewModel)
                {
                    if (toolTabs.Count > 0)
                    {
                        toolIdx         = toolIdx < toolTabs.Count ? toolIdx : toolTabs.Count - 1;
                        selectedToolTab = toolTabs[toolIdx];
                    }
                }
                await FocusTab(selectedToolTab);
            }
            else
            {
                editorTabs.Remove(tabViewModel);
                if (selectedEditorTab == tabViewModel)
                {
                    if (editorTabs.Count > 0)
                    {
                        editorIdx         = editorIdx < editorTabs.Count ? editorIdx : editorTabs.Count - 1;
                        selectedEditorTab = editorTabs[editorIdx];
                    }
                }
                await FocusTab(selectedEditorTab);
            }

            Session.RootViewModel.Tabs.Remove(tabViewModel);
        }