예제 #1
0
        public static async Task PrintName()
        {
            string name;

            using var grpcChannel = GrpcChannel.ForAddress("https://localhost:5001");
            var grpcClient = new Greeter.GreeterClient(grpcChannel);

            Console.Write("Enter your name:");
            name = Console.ReadLine();
            var reply = await grpcClient.SayHelloAsync(new HelloRequest { Name = name });

            Console.WriteLine(string.Format("{0}", reply.Message));
        }
예제 #2
0
        public static async Task ExecuteOperation(Greeter.GreeterClient greeterClient, int i)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            var       r         = await greeterClient.SayHelloAsync(new HelloRequest()
            {
                Name = "Test" + i
            }).ResponseAsync;

            stopwatch.Stop();

            OperationCount++;
            Console.WriteLine($"Ms: {stopwatch.ElapsedMilliseconds} Elapsed: {stopwatch.Elapsed}");
        }
예제 #3
0
        static async void Request1()
        {
            var input = new HelloRequest {
                Name = "Tim"
            };

            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new Greeter.GreeterClient(channel);

            var reply = await client.SayHelloAsync(input);

            Console.WriteLine(reply.Message);
        }
        static async Task Main(string[] args)
        {
            var input = new HelloRequest {
                Name = "test"
            };

            var channel = GrpcChannel.ForAddress("https://localhost:5001/");
            var client  = new Greeter.GreeterClient(channel);
            var reply   = await client.SayHelloAsync(input);

            Console.WriteLine(reply.Message);
            Console.ReadLine();
        }
예제 #5
0
        static async Task Main(string[] args)
        {
            var channel     = GrpcChannel.ForAddress("https://localhost:5001");
            var connection  = new Greeter.GreeterClient(channel);
            var connection2 = new Client.ClientClient(channel);

            do
            {
                Console.WriteLine(" 1 - Per Salutare \n 2 - Per ricevere \n 3 - Per inviare");
                switch (Console.ReadLine())
                {
                case "1":

                    var input1 = new HelloRequest {
                        Name = "Step"
                    };
                    var reply = await connection.SayHelloAsync(input1);

                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine(reply.Message);
                    break;

                case "2":
                    for (int i = 0; i < 5; i++)
                    {
                        var clientRequested = new ClientLookupModel {
                            Id = i
                        };

                        var reply2 = await connection2.GetClientInfoAsync(clientRequested);

                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine($"Age:{reply2.Age}\n FirstName:{reply2.FirstName}\n LastName:{reply2.LastName}\n IsItWarner?:{reply2.IsIt}");
                    }
                    break;

                case "3":
                    var input3 = new ClientModel {
                        Age = 10, FirstName = "Dot", LastName = "Princess Angelina Contessa Louisa Francesca Banana Fanna Bo Besca III", IsIt = true
                    };
                    var reply3 = await connection2.SaveClientInfoAsync(input3);

                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine(reply3.Success);
                    break;
                }

                Console.ResetColor();
                Console.WriteLine("\n\n");
            }while (true);
        }
예제 #6
0
        private static async Task SimpleCall(Greeter.GreeterClient client)
        {
            var result = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(result))
            {
                return;
            }

            var reply = await client.SayHelloAsync(new HelloRequest { Name = result });

            Console.WriteLine("Greeting: " + reply.Message);
            Console.WriteLine();
        }
예제 #7
0
파일: Program.cs 프로젝트: romangert/prj
        static async Task InvorkeGrpcByInterseptor(GrpcChannel channel)
        {
            // The port number(5001) must match the port of the gRPC server.
            //using var channel = CreateAuthenticatedChannel(address);
            var client  = new Greeter.GreeterClient(channel);
            var request = new HelloRequest {
                Name = "GreeterClient"
            };
            //var reply = await client.SayHelloAsync(request, headers);
            var reply = await client.SayHelloAsync(request);

            Console.WriteLine("Greeting: " + reply.Message);
            // Console.WriteLine("Press any key to exit...");
            //Console.ReadKey();
        }
예제 #8
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("=== gRPC demo client ===");

            var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var client = new Greeter.GreeterClient(channel);

            Console.WriteLine($"Sending request to Greet service ...");

            var reply = await client.SayHelloAsync(new HelloRequest { Name = "Josip" });

            Console.WriteLine($"Reply from server: " + reply.Message);

            //Console.ReadKey();
        }
예제 #9
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Please type your name: ");
            var input = new HelloRequest {
                Name = Console.ReadLine()
            };

            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new Greeter.GreeterClient(channel);

            await client.SayHelloAsync(input);

            //  Console.WriteLine(reply.Message);

            Console.ReadLine();
        }
예제 #10
0
파일: Program.cs 프로젝트: romangert/prj
        static async Task InvorkeGrpc(string address)
        {
            // The port number(5001) must match the port of the gRPC server.
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var headers = new Metadata();

            headers.Add("Authorization", $"Bearer {_token}");
            var client  = new Greeter.GreeterClient(channel);
            var request = new HelloRequest {
                Name = "GreeterClient"
            };
            var reply = await client.SayHelloAsync(request, headers);

            Console.WriteLine("Greeting: " + reply.Message);
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
예제 #11
0
        static async Task Main(string[] args)
        {
            var input = new HelloRequest {
                Name = "Fred"
            };

            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new Greeter.GreeterClient(channel);

            var reply = await client.SayHelloAsync(input);

            Console.WriteLine(reply.Message);


            channel = GrpcChannel.ForAddress("https://localhost:5001");
            var customerClient = new Customer.CustomerClient(channel);


            var clientRequested = new CustomerLookupModel {
                UserId = 2
            };

            var customer = await customerClient.GetCustomerInfoAsync(clientRequested);

            Console.WriteLine($"{customer.FirstName} { customer.LastName }");

            Console.WriteLine();
            Console.WriteLine("New Customer list");
            Console.WriteLine();


            using (var call = customerClient.GetNewCustomers(new NewCustomerRequest()))
            {
                while (await call.ResponseStream.MoveNext())
                {
                    var currentCustomer = call.ResponseStream.Current;

                    Console.WriteLine($"{currentCustomer.FirstName} { currentCustomer.LastName } {currentCustomer.EmailAdress}");
                }
            }



            Console.ReadLine();
        }
예제 #12
0
        static async Task Main(string[] args)
        {
            var url = string.Empty;

#if DEBUG
            url = "https://localhost:5001";
#else
            url = "https://localhost";
#endif

            var channel = GrpcChannel.ForAddress(url);
            var client  = new Greeter.GreeterClient(channel);
            var reply   = await client.SayHelloAsync(
                new HelloRequest { Name = "CoreDX" });

            Console.WriteLine("Greeter 服务返回数据: " + reply.Message);
            Console.ReadKey();
        }
예제 #13
0
        private static async Task Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new Greeter.GreeterClient(channel);

            var reply = await client.SayHelloAsync(new HelloRequest { Name = "悟空" });

            Console.WriteLine("调用Greeter服务 : " + reply.Message);

            var ss = new MyMath.MyMathClient(channel);

            var ssReply = await ss.AddAsync(new AddRquest { X = 10, Y = 11 });

            Console.WriteLine("调用MyMath服务 : " + ssReply.Sum);

            Console.ReadLine();
        }
예제 #14
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("begins: ");
            var serverAddress = "http://localhost:6000";    // + ipaddress;

            // This switch must be set before creating the GrpcChannel/HttpClient.
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

            var input = new HelloRequest {
                Name = "Leo"
            };
            var channel = GrpcChannel.ForAddress(serverAddress);
            var client  = new Greeter.GreeterClient(channel);
            var reply   = await client.SayHelloAsync(input);

            Console.WriteLine(reply.Message);
            Console.ReadLine();
        }
예제 #15
0
        static async Task Main(string[] args)
        {
            //var httpClientHandler = new HttpClientHandler();
            //// Return `true` to allow certificates that are untrusted/invalid
            //httpClientHandler.ServerCertificateCustomValidationCallback =
            //    HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
            //var httpClient = new HttpClient(httpClientHandler);

            var channel = GrpcChannel.ForAddress("https://localhost:50051");
            var client  = new Greeter.GreeterClient(channel);

            var response = await client.SayHelloAsync(new HelloRequest
            {
                Name = "Anshul"
            });

            Console.WriteLine(response.Message);
            Console.WriteLine("Hello World!");
        }
예제 #16
0
        static async Task Main(string[] args)
        {
            var handler     = new HttpClientHandler();
            var certificate = new X509Certificate2("clientl4.pfx", "1234");

            handler.ClientCertificates.Add(certificate);

            var channel = GrpcChannel.ForAddress("https://localhost:44379", new GrpcChannelOptions
            {
                HttpClient = new HttpClient(handler)
            });

            var client = new Greeter.GreeterClient(channel);
            var reply  = await client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" });

            Console.WriteLine("Greeting: " + reply.Message);
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
예제 #17
0
        static async Task Main(string[] args)
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

            // this does not work as it goes through the yarp proxy
            var channel = GrpcChannel.ForAddress("http://localhost:8000");

            // but this works as it connects directly to the grpc service
            // var channel = GrpcChannel.ForAddress("http://localhost:6000");

            var client = new Greeter.GreeterClient(channel);

            var helloRequest = new HelloRequest {
                Name = "Client"
            };

            var response = await client.SayHelloAsync(helloRequest);

            Console.WriteLine($"Response from greeter service is {response.Message}");
        }
예제 #18
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var input = new HelloRequest()
            {
                Name = "Hussain"
            };
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new Greeter.GreeterClient(channel);

            var reply = await client.SayHelloAsync(input);

            Console.WriteLine(reply.Message);

            var reply2 = await Save();

            Console.WriteLine(reply2.IsSaved.ToString());
            Console.ReadLine();
        }
예제 #19
0
        static async Task Main(string[] args)
        {
            var personGenerator = new PersonGenerator();
            var person          = personGenerator.GetNewPerson();

            var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var client = new Greeter.GreeterClient(channel);

            Console.WriteLine("Hello from client");
            var input = new HelloRequest {
                Name = person.FullName
            };
            var reply = await client.SayHelloAsync(input);

            Console.WriteLine(reply.Message);

            var customerService = new Customer.CustomerClient(channel);
            var customerId      = new CustomerLookupModel {
                UserId = new Random().Next(1, 100)
            };
            var userFound = customerService.GetCustomerInfo(customerId);

            Console.WriteLine($"Name: {userFound.Fullname}\nEmailAddress:{userFound.EmailAddress}\nGender:{userFound.Gender}\nId:{userFound.UserId}");

            //var input2 = new CrowdLookupModel { UserIds = new Google.Protobuf.Collections.RepeatedField<CustomerLookupModel> { customerId, customerId } };
            var cancel = new CancellationToken();

            using (var call = customerService.GetCrowdInfoFromId(customerId))
            {
                while (await call.ResponseStream.MoveNext(cancel))
                {
                    var current = call.ResponseStream.Current;
                    Console.WriteLine($"Name: {current.Fullname}");
                }
            }



            Console.ReadLine();
        }
예제 #20
0
        static async Task RunAsync(string endpoint, string prefix)
        {
            // The port number(5001) must match the port of the gRPC server.
            using var channel = GrpcChannel.ForAddress(endpoint);
            var client = new Greeter.GreeterClient(channel);
            var reply  = await client.SayHelloAsync(new HelloRequest { Name = $"{prefix} GreeterClient" });

            Console.WriteLine("Greeting: " + reply.Message);

            // duplex
            var requestHeaders = new Metadata
            {
                { "x-host-port", "10-0-0-10" },
            };

            using var streaming = client.StreamingBothWays(requestHeaders);
            var readTask = Task.Run(async() =>
            {
                await foreach (var response in streaming.ResponseStream.ReadAllAsync())
                {
                    Console.WriteLine(response.Message);
                }
            });

            var i = 0;

            while (i++ < 100)
            {
                await streaming.RequestStream.WriteAsync(new HelloRequest
                {
                    Name = $"{prefix} {i}",
                });

                await Task.Delay(TimeSpan.FromSeconds(1));
            }

            await streaming.RequestStream.CompleteAsync();

            await readTask;
        }
예제 #21
0
        static async Task Main(string[] args)
        {
            // Ignore the invalid certificate.
            // WARNING:
            // Untrusted certificates should only be used during app development.
            // Production apps should always use valid certificates.
            var httpClientHandler = new HttpClientHandler();

            // Return `true` to allow certificates that are untrusted/invalid.
            httpClientHandler.ServerCertificateCustomValidationCallback =
                HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;

            var httpClient = new HttpClient(httpClientHandler);

            // Create gRPC channel.
            var address = "https://localhost:5001";
            // Option to ignore ntrusted/invalid certificate.
            var channelOptions = new GrpcChannelOptions {
                HttpClient = httpClient
            };

            using var channel = GrpcChannel.ForAddress(address, channelOptions);

            // Create gRPC client.
            var client = new Greeter.GreeterClient(channel);

            Console.Write("Enter your first name: ");
            var name = Console.ReadLine();

            var request = new HelloRequest {
                Name = name
            };
            var reply = await client.SayHelloAsync(request);

            Console.WriteLine("Server reply: " + reply.Message);

            Console.WriteLine("\nPress any key to quit...");
            Console.ReadKey();
        }
        static async Task Main(string[] args)
        {
            // var input = new HelloRequest { Name = "Tim" };
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new Greeter.GreeterClient(channel);


            //  var reply = await client.SayHelloAsync(input);

            // Console.WriteLine(reply.Message);

            Console.WriteLine("Tape a name: ");

            //Console.ReadLine();

            string name = Console.ReadLine();

            var response = await client.SayHelloAsync(new HelloRequest { Name = name });

            Console.WriteLine("\n" + "Press any key to exit...");
            Console.ReadKey();
        }
예제 #23
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Calling a GRPC Service");
            Console.Write("Hit enter to do the deed");
            Console.ReadLine();
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var client = new Greeter.GreeterClient(channel);

            var reply = await client.SayHelloAsync(new HelloRequest { Name = "Putintane" });

            Console.WriteLine($"Got the response {reply.Message}");

            Console.WriteLine("Planning your route...");


            var clientRouting = new DrivingRouter.DrivingRouterClient(channel);
            var request       = new RouteRequest {
                Street = "555 Mockingbird Ct.", City = "Des Moines", Zip = "23892"
            };
            var replyRoute = await clientRouting.PlanRouteAsync(request);

            Console.WriteLine("Arriving at " + replyRoute.ArrivalTime);
            Console.WriteLine("Miles: " + replyRoute.Miles);
            foreach (var step in replyRoute.Steps)
            {
                Console.WriteLine($"\t{step}");
            }

            Console.WriteLine("Hit Enter to Start Turn By Turn Directions");
            Console.ReadLine();
            var client3       = new TurnByTurn.TurnByTurnClient(channel);
            var streamingCall = client3.StartGuidance(new Empty());

            await foreach (var step in streamingCall.ResponseStream.ReadAllAsync())
            {
                Console.WriteLine($"Turn {step.Direction} at {step.Road}");
            }
        }
예제 #24
0
        private async void btnSayHello_Click(object sender, RoutedEventArgs e)
        {
            var window = new Windows.SayHello {
                Owner = this
            };

            if (window.ShowDialog() ?? false)
            {
                try
                {
                    WriteLine("Method: SayHello");
                    WriteLine("Request: {0}", window.Value);
                    var result = await Client.SayHelloAsync(new HelloRequest { Name = window.Value });

                    WriteLine("Response: {0}", result.Message);
                }
                catch (System.Exception ex)
                {
                    WriteLine("Error: {0}", ex.Message);
                }
            }
        }
예제 #25
0
        static async Task Main(string[] args)
        {
            int x = 0;

            Console.WriteLine("Hello World!");
            var channel        = GrpcChannel.ForAddress("https://localhost:5001");
            var greeterClient  = new Greeter.GreeterClient(channel);
            var customerClient = new Customers.CustomersClient(channel);
            var reply          = await greeterClient.SayHelloAsync(new HelloRequest { Name = "Jon-Ajumobi Olamide D." });

            Console.WriteLine($"Message is: {reply.Message}");

            using (var customer = customerClient.GetCustomers(new EmptyModel()))
            {
                while (await customer.ResponseStream.MoveNext())
                {
                    var current = customer.ResponseStream.Current;
                    Console.WriteLine($"{++x}. Customer Name: {current.Name}, Customer Email: {current.Email}");
                }
            }
            Console.ReadLine();
        }
예제 #26
0
        static async Task Main(string[] args)
        {
            //http1方式要加下面这个段,不然有异常
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);//使用HTTP方式

            //服务端地址
            using var channel = GrpcChannel.ForAddress("http://localhost:50051");
            var client = new Greeter.GreeterClient(channel);
            var reply  = await client.SayHelloAsync(
                new HelloRequest { Name = "GreeterClient123" });

            var reply1 = await client.GetNameAsync(new HelloRequest { Name = "我是谁?" });

            Console.WriteLine();
            Console.WriteLine("Greeting: " + reply.Message);
            Console.WriteLine();
            Console.WriteLine("回复:" + reply1.Message);
            Console.WriteLine();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();

            await run1();
        }
예제 #27
0
        static async Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new Greeter.GreeterClient(channel);

            var timer = new Stopwatch();

            timer.Start();

            for (var i = 0; i < 10_000; i++)
            {
                var reply = await client.SayHelloAsync(
                    new HelloRequest { Name = "GreeterClient" });

                Console.WriteLine("Greeting: " + reply.Message);
            }

            timer.Stop();
            Console.WriteLine("Time elapsed: " + Math.Round(timer.Elapsed.TotalSeconds, 3) + " seconds");

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
예제 #28
0
        static async Task Main(string[] args)
        {
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new Greeter.GreeterClient(channel);


            Console.WriteLine("Started.");

            do
            {
                Console.WriteLine("Requesting...");
                try
                {
                    var response = await client.SayHelloAsync(
                        new HelloRequest { Name = Guid.NewGuid().ToString() });

                    Console.WriteLine(response.Message);
                }
                catch (RpcException e)
                {
                    Console.WriteLine($"Status = {e.Status}, Message = {e.Message}");
                }
            } while (Console.ReadKey().Key != ConsoleKey.Escape);
        }
예제 #29
0
        static async Task Main(string[] args)
        {
            // The port number(5001) must match the port of the gRPC server.
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new Greeter.GreeterClient(channel);

            Console.WriteLine("Sending unary call...");

            var reply = await client.SayHelloAsync(
                new HelloRequest { Name = "GreeterClient" });

            Console.WriteLine("Unary response: " + reply.Message);

            Console.WriteLine("Sending request for server stream...");

            using (var call = client.SayManyHellos(new HelloRequest {
                Name = "GreeterClient"
            }))
            {
                await foreach (var response in call.ResponseStream.ReadAllAsync())
                {
                    Console.WriteLine("New element from response stream: " + response.Message);
                }
            }

            Console.WriteLine("Sending client stream...");

            var listOfNames = new List <string> {
                "John", "James", "Freddy", "David"
            };

            Console.WriteLine("Names about to be sent: " + string.Join(", ", listOfNames));

            using (var call = client.SayHelloToLastRequest())
            {
                foreach (var name in listOfNames)
                {
                    await call.RequestStream.WriteAsync(new HelloRequest { Name = name });
                }

                await call.RequestStream.CompleteAsync();

                Console.WriteLine("Response from client stream: " + (await call.ResponseAsync).Message);
            }

            Console.WriteLine("Sending bi-directional call...");

            using (var call = client.SayHelloToEveryRequest())
            {
                foreach (var name in listOfNames)
                {
                    await call.RequestStream.WriteAsync(new HelloRequest { Name = name });
                }

                await call.RequestStream.CompleteAsync();

                await foreach (var response in call.ResponseStream.ReadAllAsync())
                {
                    Console.WriteLine("Individual item from bi-directional call: " + response.Message);
                }
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
예제 #30
0
        static async Task Main(string[] args)
        {
            try
            {
                Console.WriteLine("Please provide username.");
                var username = Console.ReadLine();

                Console.WriteLine("Please provide password.");
                var password = Console.ReadLine();

                var token = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}"));

                var headers = new Metadata();
                headers.Add("Authorization", $"Basic {token}");

                AppContext.SetSwitch(
                    "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

                // The port number(5001) must match the port of the gRPC server.
                using var channel = GrpcChannel.ForAddress("http://localhost:5000");

                var client = new Greeter.GreeterClient(channel);

                Console.WriteLine("Sending unary call...");

                var reply = await client.SayHelloAsync(
                    new HelloRequest { Name = "GreeterClient" }, headers);

                Console.WriteLine("Unary response: " + reply.Message);

                Console.WriteLine("Sending request for server stream...");

                using (var call = client.SayManyHellos(new HelloRequest {
                    Name = "GreeterClient"
                }, headers))
                {
                    await foreach (var response in call.ResponseStream.ReadAllAsync())
                    {
                        Console.WriteLine("New element from response stream: " + response.Message);
                    }
                }

                Console.WriteLine("Sending client stream...");

                var listOfNames = new List <string> {
                    "John", "James", "Freddy", "David"
                };

                Console.WriteLine("Names about to be sent: " + string.Join(", ", listOfNames));

                using (var call = client.SayHelloToLastRequest(headers))
                {
                    foreach (var name in listOfNames)
                    {
                        await call.RequestStream.WriteAsync(new HelloRequest { Name = name });
                    }

                    await call.RequestStream.CompleteAsync();

                    Console.WriteLine("Response from client stream: " + (await call.ResponseAsync).Message);
                }

                Console.WriteLine("Sending bi-directional call...");

                using (var call = client.SayHelloToEveryRequest(headers))
                {
                    foreach (var name in listOfNames)
                    {
                        await call.RequestStream.WriteAsync(new HelloRequest { Name = name });
                    }

                    await call.RequestStream.CompleteAsync();

                    await foreach (var response in call.ResponseStream.ReadAllAsync())
                    {
                        Console.WriteLine("Individual item from bi-directional call: " + response.Message);
                    }
                }

                Console.WriteLine("Press any key to exit...");
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }

            Console.ReadKey();
        }