protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Tools.Add(new Hammer()); var appSettings = new AppSettings(); var logger = PluginLoaderLogger.Factory(appSettings); var appDomain = new AppDomainWrapper(AppDomain.CurrentDomain, logger); var settings = new PluginLoaderSettings(appSettings); var typeLoader = new TypeLoader <ITool>(PluginLoaderSettings.Default, logger); var assemblyNameReader = new AssemblyNameReader(); var assemblyCache = new AssemblyCache(appDomain, assemblyNameReader, logger); var assemblyLoader = new AssemblyLoader(appDomain, settings, assemblyCache, assemblyNameReader, logger); var waiter = new Waiter(logger); var assemblyResolveCache = new AssemblyResolveCache(); var pluginDependencyObjectCreator = new PluginDependencyResolverObjectCreator(appDomain, settings, assemblyLoader, waiter, assemblyResolveCache, logger); var pluginDependencyResolverFactory = new PluginDependencyResolverCacheFactory(pluginDependencyObjectCreator, logger); var pluginCacheFactory = new PluginCacheFactory <ITool>(typeLoader, pluginDependencyResolverFactory, assemblyLoader, logger); var pluginPaths = new StaticPluginPaths(new[] { "Plugins" }); var pluginLoader = new PluginLoader <ITool>(pluginPaths, pluginCacheFactory); var plugins = pluginLoader.LoadPlugins(); var objectCreator = new ObjectCreator <ITool>(); var toolPluginObjectCreator = new PluginObjectCreator <ITool>(settings, objectCreator, logger); Tools.AddRange(plugins.CreatePluginObjects(toolPluginObjectCreator)); }
public void SharedBinPathManager_ValueOnlyHasSemicolonsAndWhitespace() { // Arrange var appSettings = new NameValueCollection { { PluginLoaderSettings.PluginSharedBinPathsKey, @"; ;; ;; ;" } }; _MockAppSettings.Setup(m => m.Settings).Returns(appSettings); var settings = new PluginLoaderSettings(_MockAppSettings.Object); // Act var actualpaths = settings.GetSharedBinPaths(); // Assert Assert.IsFalse(actualpaths.Any()); _MockRepository.VerifyAll(); }
public void SharedBinPathManager_MultipleSemicolonsIgnored() { // Arrange var appSettings = new NameValueCollection { { PluginLoaderSettings.PluginSharedBinPathsKey, @"c:\bin;;;;;;c:\sharedbin\;c:\Libs" } }; _MockAppSettings.Setup(m => m.Settings).Returns(appSettings); var expectedPaths = new List <string> { @"c:\bin", @"c:\sharedbin\", @"c:\Libs" }; var settings = new PluginLoaderSettings(_MockAppSettings.Object); // Act var actualpaths = settings.GetSharedBinPaths(); // Assert Assert.IsTrue(actualpaths.SequenceEqual(expectedPaths)); _MockRepository.VerifyAll(); }