コード例 #1
0
        public void ProcessCompanySalary(string[,] employeesArray)
        {
            string          Id           = null;
            string          Name         = null;
            string          Designation  = null;
            string          Salary       = null;
            List <Employee> listEmployee = new List <Employee>();

            for (int i = 0; i < employeesArray.GetLength(0); i++)
            {
                for (int j = 0; j < employeesArray.GetLength(1); j++)
                {
                    if (j == 0)
                    {
                        Id = employeesArray[i, j];
                    }
                    else if (j == 1)
                    {
                        Name = employeesArray[i, j];
                    }
                    else if (j == 1)
                    {
                        Designation = employeesArray[i, j];
                    }
                    else
                    {
                        Salary = employeesArray[i, j];
                    }
                }
                listEmployee.Add(new Employee(Convert.ToInt32(Id), Name, Designation, Convert.ToDecimal(Salary)));
            }
            Console.WriteLine("Adapter converted Array of Employee to List of Employee");
            Console.WriteLine("Then delegate to the ThirdPartyBillingSystem for processing the employee salary\n");
            thirdPartyBillingSystem.ProcessSalary(listEmployee);
        }
コード例 #2
0
        public void ProcessSalary(string[][] employees)
        {
            List <Employee> allemployees = new List <Employee>();

            foreach (string[] employee in employees)
            {
                Employee em = new Employee(Convert.ToInt32(employee[0]), employee[1], employee[2], Convert.ToDecimal(employee[3]));
                allemployees.Add(em);
            }
            billingSystem = new ThirdPartyBillingSystem();
            billingSystem.ProcessSalary(allemployees);
        }