Beispiel #1
0
        public static MyTask GetMyTaskByXmlElement(XmlElement elem)
        {
            string name  = elem.GetElementsByTagName("Name")?.Item(0).InnerText;
            int    level = Convert.ToInt32(elem.GetElementsByTagName("Level")?.Item(0)?.InnerText);

            MyTask res = new MyTask(name, level);

            res.CreateTime = Convert.ToDateTime(elem.GetElementsByTagName("CreateTime")?.Item(0)?.InnerText);
            res.Id         = Convert.ToInt32(elem.GetElementsByTagName("Id")?.Item(0)?.InnerText);
            res.SetStatusByString(elem.GetElementsByTagName("Status")?.Item(0)?.InnerText);
            res.Revealed = Convert.ToBoolean(elem.GetElementsByTagName("Reveal")?.Item(0)?.InnerText);

            var subTasksElem = elem.GetElementsByTagName("SubTasks")?.Item(0);

            if (subTasksElem == null || subTasksElem.HasChildNodes == false)
            {
                return(res);
            }

            //Рекурсивно преобразовываем подзадачи
            foreach (var subTaskElem in subTasksElem?.SelectNodes("Task"))
            {
                res.SubTasks.Add(MyTaskXmlPresenter.GetMyTaskByXmlElement(subTaskElem as XmlElement));
            }

            return(res);
        }
Beispiel #2
0
        //public static MyProject GetMyProjectFromXmlElement(XmlElement elem)
        //{
        //    MyProject proj = new MyProject("");
        //    if (MyTaskXmlPresenter.GetMyProjectFromXmlElement(ref proj, elem))
        //    {
        //        return proj;
        //    }

        //    return null;
        //}

        public static bool GetMyProjectFromXmlElement(ref MyProject proj, XmlElement elem)
        {
            if (elem == null)
            {
                return(false);
            }
            if (elem.Name != "Project")
            {
                return(false);
            }

            proj.Name        = elem.GetElementsByTagName("Name")?.Item(0)?.InnerText;
            proj.Id          = elem.GetElementsByTagName("Id")?.Item(0)?.InnerText;
            proj.CreateTime  = Convert.ToDateTime(elem.GetElementsByTagName("CreateTime")?.Item(0)?.InnerText);
            proj.Description = elem.GetElementsByTagName("Description")?.Item(0)?.InnerText;

            proj.TaskRoot =
                MyTaskXmlPresenter.GetMyTaskByXmlElement(elem.GetElementsByTagName("Task")?.Item(0) as XmlElement);
            return(true);
        }