Ejemplo n.º 1
0
        const int leagueId          = 2; // English Premier League

        static async Task Main(string[] args)
        {
            Console.WriteLine("Press any key to begin...");
            Console.ReadKey();

            try
            {
                // Calling the service
                using var channel = GrpcChannel.ForAddress(serviceAddress);
                var client   = new Greeter.GreeterClient(channel);
                var response = await client.GetCurrentStandingsAsync(
                    new CurrentStandingsRequest { LeagueId = leagueId });

                if (response?.Stangings == null)
                {
                    throw new NullReferenceException("Could not get data from service");
                }

                // Generating result view
                Console.WriteLine(GenerateResult(response.Stangings));
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error occured: {ex.Message}");
            }
        }