Ejemplo n.º 1
0
        public SudoExercise[] SelectExercises(SudoDifficulty difficulty)
        {
            List <SudoExercise> exerciseList = new List <SudoExercise>();
            XmlElement          dataelement  = this.GetDifficultyElement(difficulty);

            foreach (XmlNode node in dataelement.ChildNodes)
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    break;
                }
                XmlElement ele = (XmlElement)node;
                exerciseList.Add(SudoExercise.Parse(ele));
            }
            return(exerciseList.ToArray());
        }
Ejemplo n.º 2
0
        internal static SudoExercise Parse(XmlElement element)
        {
            SudoExercise exercise = new SudoExercise();

            exercise.ID             = XmlHelper.GetElementByName(element, "ID").InnerText;
            exercise.CreaterEmail   = XmlHelper.GetElementByName(element, "CreaterEmail").InnerText;
            exercise.PlayerEmail    = XmlHelper.GetElementByName(element, "PlayerEmail").InnerText;
            exercise.SingleExercise = XmlHelper.GetElementByName(element, "Exercise").InnerText;
            exercise.Solution       = XmlHelper.GetElementByName(element, "Solution").InnerText;
            string durationString = XmlHelper.GetElementByName(element, "SolveDuration").InnerText;

            if (string.IsNullOrEmpty(durationString) || durationString == "0")
            {
                exercise.SolveDuration = DateTime.Parse(durationString);
            }
            exercise.SolveTime = int.Parse(XmlHelper.GetElementByName(element, "SolveTime").InnerText);
            return(exercise);
        }
Ejemplo n.º 3
0
        public void CreatDoExerciseElement(SudoDifficulty difficulty, SudoExercise exercise)
        {
            XmlDocument rootDoc     = (XmlDocument)(this.BaseXmlNode);
            XmlElement  dataElement = rootDoc.CreateElement("data");

            XmlElement dataChildElement;

            dataChildElement           = rootDoc.CreateElement("ID");
            dataChildElement.InnerText = exercise.ID;
            dataElement.AppendChild(dataChildElement);

            dataChildElement           = rootDoc.CreateElement("Exercise");
            dataChildElement.InnerText = exercise.SingleExercise;
            dataElement.AppendChild(dataChildElement);

            dataChildElement           = rootDoc.CreateElement("Solution");
            dataChildElement.InnerText = exercise.Solution;
            dataElement.AppendChild(dataChildElement);

            dataChildElement           = rootDoc.CreateElement("CreaterEmail");
            dataChildElement.InnerText = exercise.CreaterEmail;
            dataElement.AppendChild(dataChildElement);

            dataChildElement           = rootDoc.CreateElement("PlayerEmail");
            dataChildElement.InnerText = exercise.PlayerEmail;
            dataElement.AppendChild(dataChildElement);

            dataChildElement           = rootDoc.CreateElement("SolveDuration");
            dataChildElement.InnerText = exercise.SolveDuration.ToShortTimeString();
            dataElement.AppendChild(dataChildElement);

            dataChildElement           = rootDoc.CreateElement("SolveTime");
            dataChildElement.InnerText = exercise.SolveTime.ToString();
            dataElement.AppendChild(dataChildElement);

            this.GetDifficultyElement(difficulty).AppendChild(dataElement);
        }