/// <summary> /// Creates an instance of the ITestModuleRunner /// </summary> /// <param name="runnerType">The type of the runner to create</param> /// <returns>An implementation of the ITestModuleRunner </returns> public ITestModuleRunner CreateRunner(Type runnerType) { LightweightDependencyInjectionContainer dependencyInjectionContainer = null; ITestModuleRunner runner = null; try { #if SILVERLIGHT runner = Activator.CreateInstance(runnerType) as ITestModuleRunner; #else runner = new RunnerBridge(runnerType); #endif dependencyInjectionContainer = new LightweightDependencyInjectionContainer(); var implementationSelector = new ImplementationSelector(); implementationSelector.AddAssembly(typeof(TestItem).GetAssembly()); var helpGenerator = new HelpGenerator(new LogLevelResolver(this.Parameters)); var availableParameters = helpGenerator.GetAvailableParameters(implementationSelector.Types); Dictionary <string, string> availableParametersLookup = this.Parameters.Where(kvp => availableParameters.Any(p => p.ParameterName == kvp.Key)).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); // Any TestParameters passed in are not used for injecting dependencies into RunnerBridge var configurator = new DependencyInjectionConfigurator( implementationSelector, availableParametersLookup); configurator.RootLogger = Logger.Null; configurator.ConfigureDefaultDependencies(dependencyInjectionContainer); dependencyInjectionContainer.InjectDependenciesInto(runner); } finally { if (dependencyInjectionContainer != null) { dependencyInjectionContainer.Dispose(); } } return(runner); }