Exemple #1
0
        static void PrintCart(ShoppingCartClient client)
        {
            Console.WriteLine();
            Console.WriteLine("Shopping cart currently contains the following items.");

            string[] items = client.GetCart();

            foreach (string book in items)
            {
                Console.WriteLine(book);
            }
        }
Exemple #2
0
        static void Shop(ShoppingCartClient client)
        {
            int count = client.AddItem(10000, 2);

            Console.WriteLine("AddItem({0},{1}): ItemCount={2}", 10000, 2, count);
            count = client.AddItem(10550, 5);
            Console.WriteLine("AddItem({0},{1}): ItemCount={2}", 10550, 5, count);
            count = client.RemoveItem(10550, 2);
            Console.WriteLine("RemoveItem({0},{1}): ItemCount={2}", 10550, 2, count);

            Dictionary <int, int> items = client.GetItems();

            Console.WriteLine("Items");
            foreach (KeyValuePair <int, int> item in items)
            {
                Console.WriteLine("{0}, {1}", item.Key, item.Value);
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            // Use simple binding which allows HttpCookies
            Console.WriteLine("Simple binding:");
            ShoppingCartClient client = new ShoppingCartClient("AllowCookies");

            Shop(client);
            client.Close();

            // Use smart binding which explicitly terminates session
            Console.WriteLine("Smart binding:");
            ShoppingCartClient client2 = new ShoppingCartClient("CookieSession");

            Shop(client2);
            client2.Close();

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
Exemple #4
0
        static void Main()
        {
            string input;

            ShoppingCartClient client = new ShoppingCartClient();

            Console.Write("Enter the name of the product: ");
            input = Console.ReadLine();
            client.AddItem(input);

            Console.Write("Enter the name of the product: ");
            input = Console.ReadLine();
            client.AddItem(input);

            PrintCart(client);

            client.Close();

            Console.WriteLine("Press ENTER to shut down client");
            Console.ReadLine();
        }