Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            FridgeClient client = new FridgeClient();

            client.AddFood(4, "banana");
            client.AddFood(5, "pear");

            client.AddFood(6, "tomato");

            client.AddFood(7, "pen");

            client.AddFood(8, "bottle");

            var totalFood = client.Food();

            foreach (var f in totalFood)
            {
                Console.WriteLine($"There are {f.Value} {f.Key}'s in the fridge.");
            }

            client.SubtractFood(4, "bottle");

            var totalFood1 = client.Food();

            foreach (var f in totalFood1)
            {
                Console.WriteLine($"There are {f.Value} {f.Key}'s in the fridge.");
            }


            Console.WriteLine("\nPress <Enter> to terminate the client.");
            Console.ReadLine();
            client.Close();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //Step 1: Create an instance of the WCF proxy.
            FridgeClient client = new FridgeClient();

            // Step 2: Call the service operations.
            // Call the Add service operation.
            Console.WriteLine($"There are {client.Add("apple", 10)} apples.");
            Console.WriteLine($"There are {client.Add("orange", 15)} oranges.");
            Console.WriteLine($"There are {client.Subtract("apple", 5)} apples.");
            Console.WriteLine($"There are {client.Get("pear")} pears.");
            client.Close();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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();
        }