Esempio n. 1
0
        static void Main(string[] args)
        {
            //Setup Chain of Responsibility
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver john  = new President();

            //Explain how the chain should be connected
            larry.SetSuccessor(sam);
            sam.SetSuccessor(john);

            //Generate and process purchase requests
            Purchase purchaseRequest = new Purchase(2034, 35.00, "Project X");

            larry.ProcessRequest(purchaseRequest);

            purchaseRequest = new Purchase(2035, 32590.10, "Project Y");
            larry.ProcessRequest(purchaseRequest);

            purchaseRequest = new Purchase(2036, 122100.00, "Project Z");
            larry.ProcessRequest(purchaseRequest);

            //Wait for user
            Console.ReadKey();
        }
Esempio n. 2
0
        private static Approver GetChainOfApprovers()
        {
            var larry = new Director();
            var sam   = new VicePresident();
            var tammy = new President();

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

            return(larry);
        }
Esempio n. 3
0
        static void Main()
        {
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

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

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

            larry.ProcessRequest(p);

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

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

            Console.ReadKey();
        }