/// <summary> /// Create TaskInfo and start new task /// </summary> public void StartNewTask(string tname, string[] targs) { // this LINQ exp finds taskModule from TaskModules list with name tname var tinfo = TaskModules.Where(module => module.Name == tname).Select(module => new TaskInfo(module, targs)).FirstOrDefault(); if (tinfo != null) { StartNewTask(tinfo); } }
/// <summary> /// Load .dll with task /// </summary> public void AddNewTaskModule(string taskName) { try { if (taskName.EndsWith(".dll")) // Load from .dll { string taskPath = Path.GetFullPath(taskName); taskName = taskName.Substring(0, taskName.Length - 4); var taskAssembly = Assembly.LoadFile(taskPath); var taskCore = taskAssembly.GetType(taskName + ".TaskCore"); TaskModules.Add(new TaskModuleInfo(taskName, taskAssembly, taskCore)); } else // load built-in Task { var taskCore = Type.GetType("Rangeen.BuiltInTasks." + taskName); TaskModules.Add(new TaskModuleInfo(taskName, null, taskCore)); } } catch (Exception e) { Console.WriteLine("[TaskManager] AddNewTaskModule Exception: " + e.Message + "\n" + e.StackTrace); } }