Ejemplo n.º 1
0
        static async Task Main(string[] args)
        {
            var serverAddress = "https://localhost:5001";

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                // The following statement allows you to call insecure services. To be used only in development environments.
                AppContext.SetSwitch(
                    "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
                serverAddress = "http://localhost:5000";
            }

            var channel       = GrpcChannel.ForAddress(serverAddress);
            var client        = new CreditRatingCheck.CreditRatingCheckClient(channel);
            var creditRequest = new CreditRequest {
                CustomerId = "id0201", Credit = 7000
            };
            var reply = await client.CheckCreditRequestAsync(creditRequest);

            Console.WriteLine($"Credit for customer {creditRequest.CustomerId} {(reply.IsAccepted ? "approved" : "rejected")}!");
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();

            creditRequest = new CreditRequest {
                CustomerId = "id201", Credit = 7000
            };
            reply = await client.CheckCreditRequestAsync(creditRequest);

            Console.WriteLine($"Credit for customer {creditRequest.CustomerId} {(reply.IsAccepted ? "approved" : "rejected")}!");
            Console.WriteLine("Press any key to exit...");
        }
Ejemplo n.º 2
0
        static async Task Main(string[] args)
        {
            var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var client1         = new Greeter.GreeterClient(channel);
            var greetingRequest = new HelloRequest {
                Name = "Beltrán"
            };
            var reply1 = await client1.SayHelloRequestAsync(greetingRequest);

            Console.WriteLine(reply1.Message);
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();


            var client        = new CreditRatingCheck.CreditRatingCheckClient(channel);
            var creditRequest = new CreditRequest {
                CustomerId = 201, CreditQuantity = 7000
            };
            var reply = await client.CheckCreditRequestAsync(creditRequest);

            Console.WriteLine($"El credito para el cliente con Id {creditRequest.CustomerId} esta {(reply.IsAccepted ? "aprobado" : "rechazado")}!");
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();

            creditRequest = new CreditRequest {
                CustomerId = 201, CreditQuantity = 40000
            };
            reply = await client.CheckCreditRequestAsync(creditRequest);

            Console.WriteLine($"El credito para el cliente con Id {creditRequest.CustomerId} esta {(reply.IsAccepted ? "aprobado" : "rechazado")}!");

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Ejemplo n.º 3
0
        static async Task Main(string[] args)
        {
            var channel       = GrpcChannel.ForAddress("https://localhost:5001");
            var client        = new CreditRatingCheck.CreditRatingCheckClient(channel);
            var creditRequest = new CreditRequest {
                CustomerId = "vany", Credit = 1000
            };
            var reply = await client.CheckCreditRequestAsync(creditRequest);

            Console.WriteLine($"Credit for customer {creditRequest.CustomerId}: { (reply.IsAccepted ? "approved":"rejected")}!");
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Ejemplo n.º 4
0
        // Comment the following method if you are running on MacOS
        static async Task Main(string[] args)
        {
            // The port number(5001) must match the port of the gRPC server.
            var channel       = GrpcChannel.ForAddress("https://localhost:5001");
            var client        = new CreditRatingCheck.CreditRatingCheckClient(channel);
            var creditRequest = new CreditRequest {
                CustomerId = "id0201", Credit = 7000
            };
            var reply = await client.CheckCreditRequestAsync(creditRequest);

            Console.WriteLine($"Credit for customer {creditRequest.CustomerId} {(reply.IsAccepted ? "approved" : "rejected")}!");
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Ejemplo n.º 5
0
        static async Task Main(string[] args)
        {
            //Disable TLS
            AppContext.SetSwitch(
                "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

            var channel       = GrpcChannel.ForAddress("http://localhost:5000");
            var client        = new CreditRatingCheck.CreditRatingCheckClient(channel);
            var creditRequest = new CreditRequest {
                CustomerId = "id0201", Credit = 7000
            };
            var response = await client.CheckCreditRequestAsync(creditRequest);

            Console.WriteLine($"Credit for customer {creditRequest.CustomerId} is {(response.IsAccepted ? "Accepted" : "Rejected")}");
            Console.ReadKey();
        }
Ejemplo n.º 6
0
        static async Task Main(string[] args)
        {
            var httpHandler = new HttpClientHandler();

            httpHandler.ServerCertificateCustomValidationCallback =
                HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;

            var channel = GrpcChannel.ForAddress("https://localhost:5001", new GrpcChannelOptions {
                HttpHandler = httpHandler
            });

            var client        = new CreditRatingCheck.CreditRatingCheckClient(channel);
            var creditRequest = new CreditRequest {
                CustomerId = "id0201", Credit = 7000
            };
            var reply = await client.CheckCreditRequestAsync(creditRequest);

            Console.WriteLine($"Credit for customer {creditRequest.CustomerId} {(reply.IsAccepted ? "approved" : "rejected")}!");
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }