/// <summary> /// The creator. /// </summary> /// <param name="taskItem"> /// The task item. /// </param> /// <returns> /// The <see cref="ITask"/>. /// </returns> public ITask Creator(string taskItem) { var taskDoc = XDocument.Parse(taskItem); var taskAttribute = taskDoc.Element("Task"); var scheduleElement = taskAttribute.Element("Schedule"); // create task instance ITaskMaker taskMaker = this.taskFactory.CreateTaskMaker( taskAttribute.Element("Name") .GetValueOrDefault(string.Empty)); ITask task = taskMaker.MakeTask(taskItem); task.Id = Convert.ToInt32(taskAttribute.Element("Id").Value); task.Description = taskAttribute.Element("Description") .GetValueOrDefault(string.Empty); // create schedule instance for task task.Schedule = this.scheduleFactory.CreateSchedule( scheduleElement.Element("Type") .GetValueOrDefault(string.Empty)); task.Schedule.SetSchedule(scheduleElement.ToString()); return(task); }
public string CreateTask(string from, string to) { if (taskMaker == null) { taskMaker = new TaskMaker(); } return(taskMaker.CreateTask(from, to)); }
public void CreateTaskTest() { TaskFactory taskFactory = new TaskFactory(); string taskName = TestContext.DataRow["TaskName"].ToString(); string expected = TestContext.DataRow["Expected"].ToString(); ITaskMaker actual = taskFactory.CreateTaskMaker(taskName); Assert.AreEqual(expected, ((ITask)actual).Name); }
public AsyncTask(ITaskMaker maker) { _maker = maker; }