コード例 #1
0
        public static List <Student> parseStudents(DataSet input)
        {
            List <Student> students = new List <Student>();

            foreach (DataRow row in input.Tables[0].Rows)
            {
                students.Add(StudentParser.parseStudent(row[1].ToString(), row[2].ToString(), row[3].ToString()));
            }
            return(students);
        }
コード例 #2
0
    private SchoolParser InitializeParser(ParseType parseType)
    {
        SchoolParser parser;

        switch (parseType)
        {
        default:
            parser = new SchoolParser(SchoolDataJson.text);
            break;

        case ParseType.Student:
            parser = new StudentParser(SchoolDataJson.text);
            break;

        case ParseType.Teacher:
            parser = new TeacherParser(SchoolDataJson.text);
            break;
        }
        return(parser);
    }
コード例 #3
0
        public void ParseUserData()
        {
            StudentParser studentParser = new StudentParser(schoolJsonData);

            studentParser.ParseJson();

            Userdata first = studentParser.SchoolData.userdata[0];

            Assert.AreEqual("Roy", first.name);
            Assert.AreEqual("van Borkel", first.surname);
            Assert.AreEqual("MALE", first.gender);
            Assert.AreEqual(713863410, first.birthday);

            Userdata last = studentParser.SchoolData.userdata[studentParser.SchoolData.userdata.Count - 1];

            Assert.AreEqual("Cirilla", last.name);
            Assert.AreEqual("Riannon", last.surname);
            Assert.AreEqual("FEMALE", last.gender);
            Assert.AreEqual(383180400, last.birthday);
        }
コード例 #4
0
        public void StartApplication()
        {
            StudentParser studentParser = new StudentParser();

            Console.WriteLine("Enter the full path of xml file :");
            string filePath = Console.ReadLine();

            studentParser.ReadXmlDetails(filePath);
            List <StudentInfo>       studentInfo       = studentParser.GetStudentObject().GetListOfStudentInfo();
            List <StudentProperties> listOfStudentInfo = new List <StudentProperties>();

            foreach (StudentInfo student in studentInfo)
            {
                listOfStudentInfo.Add(new StudentProperties()
                {
                    TotalMarks = student.Getmarks(), StudentName = student.GetStudentName(), Color = student.GetPassed() ? "Green" : "Red"
                });
            }
            itemControl.ItemsSource = listOfStudentInfo;
        }
コード例 #5
0
        public void ParseClassData()
        {
            StudentParser studentParser = new StudentParser(schoolJsonData);

            studentParser.ParseJson();

            Class first = studentParser.SchoolData.classes[0];

            Assert.AreEqual(1, first.id);
            Assert.AreEqual("Class A", first.name);
            Assert.AreEqual(1, first.subjects[0]);
            Assert.AreEqual(2, first.subjects[1]);

            Class last = studentParser.SchoolData.classes[studentParser.SchoolData.classes.Count - 1];

            Assert.AreEqual(5, last.id);
            Assert.AreEqual("Class E", last.name);
            Assert.AreEqual(1, last.subjects[0]);
            Assert.AreEqual(2, last.subjects[1]);
            Assert.AreEqual(4, last.subjects[2]);
        }