예제 #1
0
            /// <summary>
            /// Entry point into console application.
            /// </summary>
            public static void Main()
            {
                // Setup Chain of Responsibility

                Approver larry = new Director();
                Approver sam   = new VicePresident();
                Approver tammy = new President();
                var      ads   = larry.GetType();

                larry.SetSuccessor(sam);
                sam.SetSuccessor(tammy);

                // Generate and process purchase requests

                Purchase p = new Purchase(2034, 350.00, "Assets");

                larry.ProcessRequest(p);

                p = new Purchase(2035, 32590.10, "Project X");
                larry.ProcessRequest(p);

                p = new Purchase(2036, 122100.00, "Project Y");
                larry.ProcessRequest(p);

                // Wait for user

                Console.ReadKey();
            }
예제 #2
0
        public static void Run()
        {
            var teamLeader     = new TeamLeader();
            var departmentHead = new DepartmentHead();
            var vicePresident  = new VicePresident();
            var ceo            = new CEO();

            teamLeader.Supervisor     = departmentHead;
            departmentHead.Supervisor = vicePresident;
            vicePresident.Supervisor  = ceo;


            teamLeader.RequestPurchase(new PurchaseRequest("3 Reams of Paper", 200));
            teamLeader.RequestPurchase(new PurchaseRequest("New Computer", 2300));
            teamLeader.RequestPurchase(new PurchaseRequest("New Server", 245400));
        }
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        public void Execute()
        {
            // Setup Chain of Responsibility
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

            larry.SetSuccessor(sam);
            sam.SetSuccessor(tammy);

            // Generate and process purchase requests
            Purchase p = new Purchase(2034, 350.00, "Assets");

            larry.ProcessRequest(p);

            p = new Purchase(2035, 32590.10, "Project X");
            larry.ProcessRequest(p);

            p = new Purchase(2036, 122100.00, "Project Y");
            larry.ProcessRequest(p);
        }
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        private static void Main()
        {
            // Setup Chain of Responsibility
              Approver larry = new Director();
              Approver sam = new VicePresident();
              Approver tammy = new President();

              larry.SetSuccessor(sam);
              sam.SetSuccessor(tammy);

              // Generate and process purchase requests
              Purchase p = new Purchase(2034, 350.00, "Assets");
              larry.ProcessRequest(p);

              p = new Purchase(2035, 32590.10, "Project X");
              larry.ProcessRequest(p);

              p = new Purchase(2036, 122100.00, "Project Y");
              larry.ProcessRequest(p);

              // Wait for user
              Console.ReadKey();
        }