示例#1
0
 public ReportGenerator(EmployeeDB employeeDb)
 {
     if (employeeDb == null)
     {
         throw new ArgumentNullException("employeeDb");
     }
     _currentOutputFormat = ReportOutputFormatType.NameFirst;
     _employeeDb          = employeeDb;
 }
示例#2
0
 public ReportGenerator(CompileDB compileDb)
 {
     if (compileDb == null)
     {
         throw new ArgumentNullException("compileDb");
     }
     _currentOutputFormat = ReportOutputFormatType.NameFirst;
     _compileDb           = compileDb;
 }
示例#3
0
        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);
        }
示例#4
0
        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;
            }
        }
示例#5
0
 public void SetOutputFormat(ReportOutputFormatType format)
 {
     _currentOutputFormat = format;
 }
示例#6
0
        public void CompileReport(ReportOutputFormatType format)
        {
            Compiler tmpComp = new Compiler();

            _compiledString = tmpComp.CompileReport(ref _employeeDb, format);
        }
示例#7
0
 public ReportGenerator(ReportCompiler reportCompiler)
 {
     _currentOutputFormat = ReportOutputFormatType.NameFirst;
     _reportCompiler      = reportCompiler;
 }
示例#8
0
 public PrintToConsole(ReportOutputFormatType format)
 {
     _format = format;
 }
示例#9
0
 public ReportPrinter()
 {
     _currentOutputFormat = ReportOutputFormatType.NameFirst;
 }
示例#10
0
 public void SetOutputFormat(ReportOutputFormatType format)
 {
     _currentOutputFormat = format;
 }
示例#11
0
 public ReportGenerator(EmployeeDB employeeDb)
 {
     if (employeeDb == null) throw new ArgumentNullException("employeeDb");
     _currentOutputFormat = ReportOutputFormatType.NameFirst;
     _employeeDb = employeeDb;
 }