private static void ExecuteTests(IExecutorPlugin executorPlugin, List <IPlatform> platforms) { ThrowIf.ArgumentNull(executorPlugin, nameof(executorPlugin)); ThrowIf.ArgumentNull(platforms, nameof(platforms)); // Hack: For now just use a single Platform. TODO: Use all Platforms later. var firstPlatform = platforms[0]; var plugins = new List <IExecutorPlugin> { executorPlugin }; executorPlugin.Computer = firstPlatform.Computers[0]; // We already have one plugin, so add 1 less than Computers.Count. for (int i = 1; i < firstPlatform.Computers.Count; ++i) { var newPlugin = executorPlugin.ClonePlugin(); newPlugin.Computer = firstPlatform.Computers[i]; plugins.Add(newPlugin); } // Run all plugins in parallel. Parallel.ForEach(plugins, plugin => { plugin.Execute(); }); }
public void executeExperimentation(String jsonExperimentSeries, IExecutorPlugin executorPlugin) { if (jsonExperimentSeries == null) { throw new ArgumentException("Argument 'jsonExperimentSeries' must " + "be a not null string object."); } if (executorPlugin == null) { throw new ArgumentException("Argument 'executorPlugin' must be a not null."); } if (!this.jparser.getJsonValidator().isSyntacticalValid(jsonExperimentSeries)) { throw new ArgumentException("Argument 'jsonExperimentSeries' must " + "be a syntactically valid JSON string."); } if (!this.jparser.getJsonValidator().isSemanticalValid(jsonExperimentSeries)) { throw new ArgumentException("Argument 'jsonExperimentSeries' must " + "be a semantically valid JSON string."); } IExperimentSeries eSeries = (IExperimentSeries)this.jparser.parse(jsonExperimentSeries); this.jbuilder.reset(); this.obuilder.reset(); executorPlugin.execute(eSeries); }
private ExecutorPluginProxy(String pluginFilePath) { bool isOk = ((!String.IsNullOrEmpty(pluginFilePath)) && (File.Exists(pluginFilePath))); if (isOk) { this.pluginFilePath = pluginFilePath; this.executorPlugin = executorPlugin = loadPlugin(pluginFilePath); } else { throw new ArgumentException("The given arguments are not valid.\n" + "pluginFilePathArg must be a valid non empty " + "string and a valid file path to an plugin file"); } }
private IExecutorPlugin loadPlugin(String pluginFilePathArg) { IExecutorPlugin loadedPlugin = null; Assembly assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(pluginFilePathArg); if (assembly != null) { Type pluginType = typeof(IExecutorPlugin); Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (!type.IsInterface && !type.IsAbstract) { if (type.GetInterface(pluginType.FullName) != null) { loadedPlugin = (IExecutorPlugin)Activator.CreateInstance(type); } } } } return(loadedPlugin); }