public Student(XmlNode xmlNode):base(
xmlNode.SelectSingleNode("PresonalDetails/FirstName").InnerText,
xmlNode.SelectSingleNode("PresonalDetails/LastName").InnerText,
xmlNode.SelectSingleNode("PresonalDetails/EGN").InnerText,
xmlNode.SelectSingleNode("PresonalDetails/HomeTown").InnerText
)
{
int facultyNumber = int.Parse(xmlNode.SelectSingleNode("FacultyNumber").InnerText);
StudentRank rank = (StudentRank)Enum.Parse(typeof(StudentRank), xmlNode.SelectSingleNode("Rank").InnerText);
//int points = int.Parse(xmlNode.SelectSingleNode("Points").InnerText);
if (facultyNumber == 0)
{
throw new ArgumentException("Faculty number cannot be zero");
}
this.coursesList = new List<Course>();
XmlNode coursesNode = xmlNode.SelectSingleNode("CoursesList");
XmlNode courseNode = coursesNode.FirstChild;
while (!(courseNode == null))
{
//Enum.Parse(cName, courseNode.InnerText.ToString());
object cName = Enum.Parse(typeof(CourseName), courseNode.InnerText.ToString());
this.AddCourse (new Course((CourseName)cName));
courseNode = courseNode.NextSibling;
}
this.GradeList = new List<Grade>();
XmlNode gradesNode = xmlNode.SelectSingleNode("GradesList");
XmlNode gradeNode = gradesNode.FirstChild;
while (!(gradeNode == null))
{
this.AddGrade(new Grade(
double.Parse(gradeNode.SelectSingleNode("Weight").InnerText),
new Course((CourseName)Enum.Parse(typeof(CourseName), gradeNode.SelectSingleNode("Course").InnerText.ToString()))
)
);
gradeNode = gradeNode.NextSibling;
}
this.FacultyNumber = facultyNumber;
this.Rank = rank;
//this.Points = points;
}