Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // 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();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //sample 2
            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.10, "Project X");
            larry.ProcessRequest(p);

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


            //sample 1
            //var message = new MessageBuilder()
            //    .setValue("hi there is a message ")
            //    .AddDestination(Destination.FAX, "9343434343")
            //    //.AddDestination(Destination.SMS, "9934834343")
            //    .AddDestination(Destination.EMAIL,"*****@*****.**")
            //    .Build();

            //var messageService = new MessageService();
            //messageService.sendMessage(message);

            Console.ReadKey();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var dir  = new Director();
            var vice = new VicePresident();

            dir.SetSuccessor(vice);
            var pres = new President();

            vice.SetSuccessor(pres);

            var expense = new Purchase {
                Number = 1, Amount = 45000.0m
            };

            dir.ProcessRequest(expense);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Entry point into console application.
 /// </summary>
 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();
 }
Exemplo n.º 5
0
        public void Main()
        {
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

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

            // Generate and process purchase requests
            var 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);
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

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

            var 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);

            Console.ReadKey();
        }
Exemplo n.º 7
0
        public static void Main()
        {
            // Setup Chain of Responsibility
            Approver director      = new Director();
            Approver vicePresident = new VicePresident();
            Approver president     = new President();

            director.SetSuccessor(vicePresident);
            vicePresident.SetSuccessor(president);

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

            director.ProcessRequest(p);

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

            p = new Purchase(2036, 122100.00, "Project Y");
            director.ProcessRequest(p);
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Chain of responsibility");

            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.10, "Project X");
            larry.ProcessRequest(p);

            p = new Purchase(2036, 122100.00, "Project Y");
            larry.ProcessRequest(p);
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            // Setup Chain of Responsibility
            Approver ronny = new Director();
            Approver bobby = new VicePresident();
            Approver ricky = new President();

            ronny.SetSuccessor(bobby);
            bobby.SetSuccessor(ricky);

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

            ronny.ProcessRequest(p);

            p = new Purchase(5675, 33390.10, "Project Poison");
            ronny.ProcessRequest(p);

            p = new Purchase(5676, 144400.00, "Project BBD");
            ronny.ProcessRequest(p);

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