Esempio n. 1
0
        static void Main(string[] args)
        {
            //Step 1: Create an instance of the WCF proxy.
            FridgeClient client = new FridgeClient();

            Console.WriteLine("Add 3 oranges");
            var total = client.AddFruit(Orange, 3);

            Console.WriteLine($"Total oranges = {total}");

            Console.WriteLine("Add 2 apples");
            total = client.AddFruit(Apple, 2);
            Console.WriteLine($"Total apples = {total}");

            Console.WriteLine("Add 1 banana");
            total = client.AddFruit(Banana, 1);
            Console.WriteLine($"Total bananas = {total}");


            Console.WriteLine("Remove 1 banana");
            total = client.RemoveFruit(Banana, 1);
            Console.WriteLine($"Total bananas = {total}");

            Console.WriteLine("Remove 1 banana (no more left)");
            total = client.RemoveFruit(Banana, 1);
            Console.WriteLine($"Total bananas = {total}");

            Console.WriteLine("Remove 2 oranges (1 left)");
            total = client.RemoveFruit(Orange, 2);
            Console.WriteLine($"Total oranges = {total}");

            Console.WriteLine("Query fruit count");
            total = client.TotalFruit();
            Console.WriteLine($"Total fruit = {total}");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //Step 1: Create an instance of the WCF proxy.
            FridgeClient client = new FridgeClient();


            var fridgeContent = client.FridgeContents();

            Console.WriteLine("Fridge intially has these fruits in it.");
            foreach (var item in fridgeContent)
            {
                Console.WriteLine(item);
            }

            int result = 0;

            result = client.GetFruitTotal();
            Console.WriteLine($"Total fruits in fridge is : {result}\n");



            string fruit = "Papaya";

            result = client.AddFruit("Papaya");
            Console.WriteLine($"{fruit} added in");

            fridgeContent = client.FridgeContents();
            Console.WriteLine("Fridge now has these fruits in it.");
            foreach (var item in fridgeContent)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine($"Total fruits in fridge is : {result}\n");

            result = client.TakeFruit(fruit);
            Console.WriteLine($"\nI took out the {fruit} and ate it");

            fridgeContent = client.FridgeContents();
            Console.WriteLine("Fridge now has these fruits in it.");
            foreach (var item in fridgeContent)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine($"Total fruits in fridge is : {result}\n");


            // Step 3: Close the client to gracefully close the connection and clean up resources.
            Console.WriteLine("\nPress <Enter> to terminate the client.");
            Console.ReadLine();
            client.Close();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //Step 1: Create an instance of the WCF proxy.
            FridgeClient client = new FridgeClient();

            int fruit = client.HowMuchFruit();

            Console.WriteLine("There are {0} pieces of fruit to start", fruit);
            Console.ReadLine();

            fruit = client.AddFruit(5);
            Console.WriteLine("There are {0} pieces of fruit left after adding {1} pieces", fruit, 5);
            Console.ReadLine();

            fruit = client.HowMuchFruit();
            Console.WriteLine("There are now {0} pieces of fruit left", fruit);
            Console.ReadLine();

            fruit = client.GetFruit(2);
            Console.WriteLine("There are now {0} pieces of fruit left after getting {1} pieces", fruit, 2);
            Console.ReadLine();

            client.Close();
        }