Exemplo n.º 1
0
        public static int Main(string[] args)
        {
            try
            {
                HelloOwinClientArguments progArgs = CommandLine.Parse <HelloOwinClientArguments>();

                TextWriter traceWriter = Console.Out;

                HelloOwinClient client = new HelloOwinClient();

                int rc = client.Run(progArgs, traceWriter).Result; // Blocking call ok because this is Main thread.

                Console.WriteLine();
                Console.WriteLine("Press any key to exit.");
                Console.ReadLine();

                return(rc);
            }
            catch (CommandLineException exception)
            {
                Console.WriteLine(exception.ArgumentHelp.Message);
                Console.WriteLine(exception.ArgumentHelp.GetHelpText(Console.BufferWidth));
                return(-1);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Error starting {0}.exe", Assembly.GetEntryAssembly()?.GetName().Name);
                Console.Error.WriteLine(ex);
                Console.Error.Flush();
                return(1);
            }
        }
Exemplo n.º 2
0
        public async Task <int> Run(HelloOwinClientArguments progArgs, TextWriter traceWriter)
        {
            string address = progArgs.Address;
            bool   useJson = progArgs.UseJson;
            string name    = progArgs.Name;

            HelloRequest request = new HelloRequest
            {
                Name = name
            };

            HelloReply reply = await Send(request, useJson, address, traceWriter);

            traceWriter.WriteLine(reply.Message);

            return(0);
        }