public void LoadFromXML(XmlNode tasks) { TaskList.TaskType type = TaskList.TaskType.Task; string description = ""; string tagRef = ""; string section = ""; bool active = true; int priority = 0; foreach (XmlNode task in tasks.ChildNodes) { switch (task.Attributes.GetNamedItem("type").Value) { case "Task": type = TaskList.TaskType.Task; break; case "Warning": type = TaskList.TaskType.Warning; break; case "Error": type = TaskList.TaskType.Error; break; } priority = Convert.ToInt32(task.Attributes.GetNamedItem("priority").Value); foreach (XmlNode property in task.ChildNodes) { if (property.Name == "Description") { description = property.Value; } else if (property.Name == "TagRef") { tagRef = property.Value; } else if (property.Name == "Section") { section = property.Value; } else if (property.Name == "Active") { active = XmlConvert.ToBoolean(property.Value); } } Add(type, description, tagRef, section, active); } }
public Task(TaskList.TaskType type, string description, string tagRef, string section, bool active) { this.type = type; this.description = description; this.tagRef = tagRef; this.section = section; this.active = active; switch (this.type) { case TaskList.TaskType.Error: this.priority = 1; break; case TaskList.TaskType.Warning: this.priority = 2; break; case TaskList.TaskType.Task: this.priority = 3; break; } }
public void Add(TaskList.TaskType type, string description, string tagRef, string section, bool active) { Add(new Task(type, description, tagRef, section, active)); }