public ReportGenerator(EmployeeDB employeeDb) { if (employeeDb == null) { throw new ArgumentNullException("employeeDb"); } _currentOutputFormat = ReportOutputFormatType.NameFirst; _employeeDb = employeeDb; }
public ReportGenerator(CompileDB compileDb) { if (compileDb == null) { throw new ArgumentNullException("compileDb"); } _currentOutputFormat = ReportOutputFormatType.NameFirst; _compileDb = compileDb; }
public List <string> CompileReport(ref EmployeeDB employeeDB, ReportOutputFormatType format) { List <string> formattedString = new List <string>(); var employees = new List <Employee>(); Employee employee; employeeDB.Reset(); // Get all employees while ((employee = employeeDB.GetNextEmployee()) != null) { employees.Add(employee); } // All employees collected - let's output them switch (format) { case ReportOutputFormatType.NameFirst: formattedString.Add("Name-first report"); foreach (var e in employees) { formattedString.Add("------------------"); formattedString.Add("Name: {0}" + (e.Name)); formattedString.Add("Salary: {0}" + e.Salary); formattedString.Add("------------------"); } break; case ReportOutputFormatType.SalaryFirst: formattedString.Add("Salary-first report"); foreach (var e in employees) { formattedString.Add("------------------"); formattedString.Add("Salary: {0}" + e.Salary); formattedString.Add("Name: {0}" + e.Name); formattedString.Add("------------------"); } break; } return(formattedString); }
public void CompileReport(ReportOutputFormatType reportFormat) { var employees = new List <Employee>(); Employee employee; _employeeDb.Reset(); // Get all employees while ((employee = _employeeDb.GetNextEmployee()) != null) { employees.Add(employee); } // All employees collected - let's output them switch (reportFormat) { case ReportOutputFormatType.NameFirst: Console.WriteLine("Name-first report"); foreach (var e in employees) { Console.WriteLine("------------------"); Console.WriteLine("Name: {0}", e.Name); Console.WriteLine("Salary: {0}", e.Salary); Console.WriteLine("------------------"); } break; case ReportOutputFormatType.SalaryFirst: Console.WriteLine("Salary-first report"); foreach (var e in employees) { Console.WriteLine("------------------"); Console.WriteLine("Salary: {0}", e.Salary); Console.WriteLine("Name: {0}", e.Name); Console.WriteLine("------------------"); } break; } }
public void SetOutputFormat(ReportOutputFormatType format) { _currentOutputFormat = format; }
public void CompileReport(ReportOutputFormatType format) { Compiler tmpComp = new Compiler(); _compiledString = tmpComp.CompileReport(ref _employeeDb, format); }
public ReportGenerator(ReportCompiler reportCompiler) { _currentOutputFormat = ReportOutputFormatType.NameFirst; _reportCompiler = reportCompiler; }
public PrintToConsole(ReportOutputFormatType format) { _format = format; }
public ReportPrinter() { _currentOutputFormat = ReportOutputFormatType.NameFirst; }
public ReportGenerator(EmployeeDB employeeDb) { if (employeeDb == null) throw new ArgumentNullException("employeeDb"); _currentOutputFormat = ReportOutputFormatType.NameFirst; _employeeDb = employeeDb; }