示例#1
0
        private static VimEditorHost GetOrCreateVimEditorHost()
        {
            var key = Thread.CurrentThread.ManagedThreadId;

            if (!s_cachedVimEditorHostMap.TryGetValue(key, out VimEditorHost host))
            {
                var editorHostFactory = new EditorHostFactory();
                editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));

                // Other Exports needed to construct VsVim
                var types = new List <Type>()
                {
                    typeof(TestableClipboardDevice),
                    typeof(TestableKeyboardDevice),
                    typeof(TestableMouseDevice),
                    typeof(global::Vim.UnitTest.Exports.VimHost),
                    typeof(VimErrorDetector),
                    typeof(DisplayWindowBrokerFactoryService),
                    typeof(AlternateKeyUtil),
                    typeof(OutlinerTaggerProvider)
                };

                editorHostFactory.Add(new TypeCatalog(types));
                editorHostFactory.Add(VimSpecificUtil.GetTypeCatalog());

                var compositionContainer = editorHostFactory.CreateCompositionContainer();
                host = new VimEditorHost(compositionContainer);
                s_cachedVimEditorHostMap[key] = host;
            }

            return(host);
        }
示例#2
0
        private static VimEditorHost CreateVimEditorHost()
        {
            var editorHostFactory = new EditorHostFactory();

            editorHostFactory.Add(new AssemblyCatalog(typeof(Vim.IVim).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(Vim.UI.Wpf.VimKeyProcessor).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(VsCommandTarget).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(ISharedService).Assembly));

            var types = new List <Type>()
            {
                typeof(Vim.VisualStudio.UnitTest.MemoryLeakTest.ServiceProvider),
                typeof(Vim.VisualStudio.UnitTest.MemoryLeakTest.VsEditorAdaptersFactoryService),
                typeof(VimErrorDetector)
            };

            editorHostFactory.Add(new TypeCatalog(types));
            editorHostFactory.Add(VimSpecificUtil.GetTypeCatalog());

            return(new VimEditorHost(editorHostFactory.CreateCompositionContainer()));
        }