public override Employees Read() { Employees employees = new Employees(); using (XmlReader reader = XmlReader.Create(this.FileName)) { Employee employee = new Employee(); while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case Field.Name: case Field.Dept: case Field.Number: case Field.Title: FileData fileData = new FileData(); fileData.Fieldname = reader.Name; if (reader.Read()) { fileData.StringValue = reader.Value; } employee.EmployeeData.Add(fileData); if (fileData.Fieldname == Field.Title) { employees.EmployeesData.Add(employee); employee = new Employee(); } break; } } } } return employees; }
public override Employees Read() { Employees employees = new Employees(); using (StreamReader sr = new StreamReader(this.FileName)) { string line = string.Empty; while (!sr.EndOfStream) { Employee employee = new Employee(); for (int i = 0; i < 4; i++) { line = sr.ReadLine(); FileData fileData = new FileData(); fileData.Fieldname = line.Split('\t')[0]; fileData.StringValue = line.Split('\t')[1]; employee.EmployeeData.Add(fileData); } employees.EmployeesData.Add(employee); } } return employees; }