static Group TestCreateGroup(Faculty faculty, int numberGroup, int studentID) { var group = new Group(faculty, numberGroup); var st = TestCreateStudent(group, studentID); foreach (var student in st) { group.Add(student); } return group; }
public static Student LoadStudentFromXML(FileStream stream, Group group) { try { var reader = new XmlTextReader(stream); var firstName = string.Empty; var middleName = string.Empty; var lastName = string.Empty; Sex sex = Sex.Male; var dateOfBirth = string.Empty; var studentID = string.Empty; var leader = false; while (reader.Read()) { switch (reader.Name) { case "student": if (reader.AttributeCount >= 1) leader = bool.Parse(reader.GetAttribute("leader")); break; case "firstName": firstName = reader.ReadString(); break; case "middleName": middleName = reader.ReadString(); break; case "lastName": lastName = reader.ReadString(); break; case "sex": Enum.TryParse(reader.ReadString(), out sex); break; case "dateOfBirth": dateOfBirth = reader.ReadString(); break; case "id": studentID = reader.ReadString(); break; } } var student = new Student(lastName, firstName, middleName, sex, group, int.Parse(studentID), dateOfBirth); if (group != null) { group.Add(student); if (leader) group.SetLeader(student); } return student; } catch (ArgumentNullException exception) { throw new ArgumentNullException(exception.Source); } catch (XmlException exception) { throw new XmlException(exception.Source); } catch (InvalidOperationException exception) { throw new InvalidOperationException(exception.Source); } }