コード例 #1
0
ファイル: Program.cs プロジェクト: jesconsa/Telerik-Academy
        internal static void Main()
        {
            // Setup employee collection
            var employees = new Employees();
            employees.Attach(new Clerk());
            employees.Attach(new Director());
            employees.Attach(new President());

            // Employees are 'visited'
            employees.Accept(new IncomeVisitor());
            employees.Accept(new VacationVisitor());
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Employees employees = new Employees();

            employees.Attach(new Clerk());
            employees.Attach(new Directory());
            employees.Attach(new President());

            employees.Accept(new IncomeVisitor());
            employees.Accept(new VacationVisitor());

            Console.ReadKey();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: ghonda/DesignerPatters
        static void Main(string[] args)
        {
            Employees e = new Employees();

            e.Attach(new Clerk());
            e.Attach(new Director());
            e.Attach(new President());

            // Employees are 'visited'

            e.Accept(new IncomeVisitor());
            e.Accept(new VacationVisitor());
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: rezacse/DesignPatterns
        public static void Main(string[] args)
        {
            var employees = new Employees();


            employees.Attach(new Clerk("Clerk", 500, 15));
            employees.Attach(new Manager("Manager", 5000, 25));


            employees.Accept(new IncomeVisitor());
            employees.Accept(new VacationVisitor());


            Console.ReadKey();
        }
コード例 #5
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // Setup employee collection
            Employees e = new Employees();
            e.Attach(new Clerk());
            e.Attach(new Director());
            e.Attach(new President());

            // Employees are 'visited'
            e.Accept(new IncomeVisitor());
            e.Accept(new VacationVisitor());

            // Wait for user
            Console.ReadKey();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: Anil1111/DesignPatterns-3
        /// <summary>
        /// The Visitor pattern represents an operation to be performed on the elements of an object structure.
        /// Whereas Strategy exposes items to a standardized interface, Visitor details a mechanism by which
        /// objects can accept a reference to another object (the visitor) which exposes an interface that the target
        /// can call upon itself.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // Who are my employees?
            Employees e = new Employees();

            e.Attach(new LineCook());
            e.Attach(new HeadChef());
            e.Attach(new GeneralManager());

            // Employees are visited, giving them 10% raises and 3 extra paid time off days.
            e.Accept(new IncomeVisitor());
            e.Accept(new PaidTimeOffVisitor());

            Console.ReadKey();
        }
コード例 #7
0
ファイル: VisitorMain.cs プロジェクト: EBojilova/CSharpHQC
        internal static void Main()
        {
            // Greshno, tai kato ne e rabota na Main metoda da vdiga zaplatatata na employee
            // Zatova se pravi IncomeVisitor, koito ima pravomostiata da ia vdiga
            var employee = new Clerk();
            employee.Income += 1000;

            // Setup employee collection
            var employees = new Employees();
            employees.Attach(new Clerk());
            employees.Attach(new Director());
            employees.Attach(new President());

            // Employees are 'visited'
            employees.Accept(new IncomeVisitor());
            employees.Accept(new VacationVisitor());
        }
コード例 #8
0
        /// <resumen>

        /// Punto de entrada en la aplicación de consola.

        /// </resumen>

        static void Main(string [] args)
        {
            // Configurar colección de empleados

            Employees e = new Employees();

            e.Attach(new Clerk());
            e.Attach(new Director());
            e.Attach(new President());

            // Los empleados son 'visitados'

            e.Accept(new IncomeVisitor());
            e.Accept(new VacationVisitor());

            // Espera al usuario

            Console.ReadKey();
        }
コード例 #9
0
        static void Main(string[] args)
        {
            //Object structure
            Employees employees = new Employees();

            //Elements
            Element clerk    = new Clerk("Edward", 500, 6);
            Element director = new Director("Jonathan", 600, 8);

            //Visitors
            IVisitor incomeVisitor   = new IncomeVisitor();
            IVisitor vacationVisitor = new VacationVisitor();

            // Attach elements to the object structure
            employees.Attach(clerk);
            employees.Attach(director);

            //Perform operation of different visitors.
            employees.Accept(incomeVisitor);
            employees.Accept(vacationVisitor);
        }
コード例 #10
0
        public static void Run()
        {
            Console.WriteLine("This real-world code demonstrates the Visitor pattern in which two objects traverse a list of Employees and performs the same operation on each Employee. The two visitor objects define different operations -- one adjusts vacation days and the other income.\n");
            Employees e = new Employees();

            e.Attach(new Clerk());
            e.Attach(new Director());
            e.Attach(new President());

            e.Accept(new IncomeVisitor());
            e.Accept(new VacationVisitor());

            /*
             * Clerk Hank's new income: $27,500.00
             * Director Elly's new income: $38,500.00
             * President Dick's new income: $49,500.00
             *
             * Clerk Hank's new vacation days: 17
             * Director Elly's new vacation days: 19
             * President Dick's new vacation days: 24
             */
        }
コード例 #11
0
        static void Main(string[] args)
        {
            var employees = new Employees();

            var director = new Director {
                Name = "Steve", Income = 100000, VacationDays = 100
            } as Employee;
            var president = new President {
                Name = "Bob", Income = 1000000, VacationDays = 10
            } as Employee;
            var clerk = new Clerk {
                Name = "Mary", Income = 10000, VacationDays = 1
            } as Employee;

            employees.EmployeesList.AddRange(new [] { director, president, clerk });

            var incomeVisitor       = new IncomeVisitor();
            var vacationDaysVisitor = new VacationVisitor();

            employees.Accept(incomeVisitor);
            employees.Accept(vacationDaysVisitor);
        }
コード例 #12
0
        static void Main(string[] args)
        {
            Employee xz  = new Engineer("小张", "工业设计部", 3000.0, 10);
            Employee xw  = new Engineer("小王", "工业设计部", 3100.0, 11);
            Employee xc  = new Engineer("小张", "营销零售部", 2800.0, 5);
            Employee xl  = new Engineer("小李", "营销零售部", 2900.0, 4);
            Employee xzh = new Engineer("小周", "财务管理部", 3200.0, 3);

            Employees employees = new Employees();

            employees.Attach(xz);
            employees.Attach(xw);
            employees.Attach(xc);
            employees.Attach(xl);
            employees.Attach(xzh);

            Visitor incomeVisitor   = new IncomeVisitor();
            Visitor vacationVisitor = new VacationVisitor();

            employees.Accept(incomeVisitor);
            employees.Accept(vacationVisitor);

            Console.ReadKey();
        }
コード例 #13
0
ファイル: Form1.cs プロジェクト: psilovehack/keylogger-haiver
        private void button6_Click(object sender, EventArgs e)
        {
            Employees empleados = new Employees();
            empleados.Attach(new Director());

            empleados.Accept(new VisitorIngreso());
        }