Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Empolyee engin = new Empolyee {
                Name = "engin demiroğ"
            };

            Empolyee salih = new Empolyee {
                Name = "salih demiroğ"
            };

            engin.AddSubordinate(salih);

            Empolyee derin = new Empolyee {
                Name = "derin demiroğ"
            };

            engin.AddSubordinate(derin);

            Contractor ali = new Contractor {
                Name = "Ali"
            };

            derin.AddSubordinate(ali);

            Empolyee ahmet = new Empolyee {
                Name = "  ahmet"
            };

            salih.AddSubordinate(ahmet);

            Console.WriteLine(engin.Name);

            foreach (Empolyee manager in engin)
            {
                Console.WriteLine("  {0}", manager.Name);

                foreach (IPerson employee in manager)
                {
                    Console.WriteLine("    {0}", employee.Name);
                }
            }


            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            /*
             *  Employee Tree Structure
             *  - Hamza
             *      - Sami
             *          - Elif
             *          - Sonya
             *      - Mahmut
             *          - Macit
             *          - Emre
             *          - Cenk
             *          - Atilla
             */

            Employee Hamza = new Employee {
                EmpID = 1, Name = "Hamza"
            };

            Employee Sami = new Employee {
                EmpID = 2, Name = "Sami"
            };
            Employee Mahmut = new Employee {
                EmpID = 3, Name = "Mahmut"
            };

            Hamza.AddSubordinate(Sami);
            Hamza.AddSubordinate(Mahmut);

            Employee Elif = new Employee {
                EmpID = 4, Name = "Elif"
            };
            Employee Sonya = new Employee {
                EmpID = 5, Name = "Sonya"
            };

            Sami.AddSubordinate(Elif);
            Sami.AddSubordinate(Sonya);

            Employee Macit = new Employee {
                EmpID = 6, Name = "Macit"
            };
            Employee Emre = new Employee {
                EmpID = 7, Name = "Emre"
            };

            Contractor Cenk = new Contractor {
                EmpID = 8, Name = "Cenk"
            };
            Contractor Atilla = new Contractor {
                EmpID = 9, Name = "Atilla"
            };

            Mahmut.AddSubordinate(Macit);
            Mahmut.AddSubordinate(Emre);
            Mahmut.AddSubordinate(Cenk);
            Mahmut.AddSubordinate(Atilla);

            Console.WriteLine($"EmpID={Hamza.EmpID}, Name={Hamza.Name}");

            foreach (Employee manager in Hamza)
            {
                Console.WriteLine($"   > EmpID={manager.EmpID}, Name={manager.Name}");

                foreach (var employee in manager)
                {
                    Console.WriteLine($"      > EmpID={employee.EmpID}, Name={employee.Name}");
                }
            }

            Console.ReadKey();
        }