public Task CreateTask(TaskConfig config) { if (_pluginTypes.ContainsKey(config.PluginAssembly)) { var type = _pluginTypes[config.PluginAssembly].SingleOrDefault(t => t.FullName == config.PluginType); if (type != null) { Task task = new Task(); task.Name = config.Name; task.Description = config.Description; task.Id = Guid.NewGuid(); task.Plugin = Activator.CreateInstance(type) as IAutomatonPlugin; task.Plugin.Load(config.Parameters); return task; } } return null; }
public Config(XmlNode node) : base(node) { var tasks = Section.SelectNodes("task"); foreach (XmlElement task in tasks) { TaskConfig r = new TaskConfig(); r.Name = task.Attributes["name"].Value; r.Description = task.Attributes["description"].Value; r.PluginAssembly = task.Attributes["pluginassembly"].Value; r.PluginType = task.Attributes["plugintype"].Value; if (task.Attributes["parameters"] != null) { r.Parameters.AddRange(task.Attributes["parameters"].Value.Split(new[]{';'})); } _tasks.Add(r); } }