Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            GrpcEnvironment.SetLogger(new ConsoleLogger());
            var parserResult = Parser.Default.ParseArguments <ClientOptions>(args)
                               .WithNotParsed(errors => Environment.Exit(1))
                               .WithParsed(options =>
            {
                Console.WriteLine("Use TLS: " + options.UseTls);
                Console.WriteLine("Use Test CA: " + options.UseTestCa);
                Console.WriteLine("Client type: " + options.ClientType);
                Console.WriteLine("Server host: " + options.ServerHost);
                Console.WriteLine("Server port: " + options.ServerPort);

                var services = new ServiceCollection();
                services.AddLogging(configure =>
                {
                    configure.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
                    configure.AddConsole(loggerOptions => loggerOptions.IncludeScopes = true);
                });

                using var serviceProvider = services.BuildServiceProvider();

                var interopClient = new InteropClient(options, serviceProvider.GetRequiredService <ILoggerFactory>());
                interopClient.Run().Wait();
            });
        }
Exemplo n.º 2
0
        public static async Task <int> Main(string[] args)
        {
            var rootCommand = new RootCommand();

            rootCommand.AddOption(new Option <string>(new string[] { "--client_type", nameof(ClientOptions.ClientType) }, () => "httpclient"));
            rootCommand.AddOption(new Option <string>(new string[] { "--server_host", nameof(ClientOptions.ServerHost) })
            {
                Required = true
            });
            rootCommand.AddOption(new Option <string>(new string[] { "--server_host_override", nameof(ClientOptions.ServerHostOverride) }));
            rootCommand.AddOption(new Option <int>(new string[] { "--server_port", nameof(ClientOptions.ServerPort) })
            {
                Required = true
            });
            rootCommand.AddOption(new Option <string>(new string[] { "--test_case", nameof(ClientOptions.TestCase) })
            {
                Required = true
            });
            rootCommand.AddOption(new Option <bool>(new string[] { "--use_tls", nameof(ClientOptions.UseTls) }));
            rootCommand.AddOption(new Option <bool>(new string[] { "--use_test_ca", nameof(ClientOptions.UseTestCa) }));
            rootCommand.AddOption(new Option <string>(new string[] { "--default_service_account", nameof(ClientOptions.DefaultServiceAccount) }));
            rootCommand.AddOption(new Option <string>(new string[] { "--oauth_scope", nameof(ClientOptions.OAuthScope) }));
            rootCommand.AddOption(new Option <string>(new string[] { "--service_account_key_file", nameof(ClientOptions.ServiceAccountKeyFile) }));
            rootCommand.AddOption(new Option <string>(new string[] { "--grpc_web_mode", nameof(ClientOptions.GrpcWebMode) }));
            rootCommand.AddOption(new Option <bool>(new string[] { "--use_winhttp", nameof(ClientOptions.UseWinHttp) }));
            rootCommand.AddOption(new Option <bool>(new string[] { "--use_http3", nameof(ClientOptions.UseHttp3) }));

            rootCommand.Handler = CommandHandler.Create <ClientOptions>(async(options) =>
            {
                var runtimeVersion = typeof(object).Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "Unknown";

                Console.WriteLine("Runtime: " + runtimeVersion);
                Console.WriteLine("Use TLS: " + options.UseTls);
                Console.WriteLine("Use WinHttp: " + options.UseWinHttp);
                Console.WriteLine("Use HTTP/3: " + options.UseHttp3);
                Console.WriteLine("Use GrpcWebMode: " + options.GrpcWebMode);
                Console.WriteLine("Use Test CA: " + options.UseTestCa);
                Console.WriteLine("Client type: " + options.ClientType);
                Console.WriteLine("Server host: " + options.ServerHost);
                Console.WriteLine("Server port: " + options.ServerPort);

                var services = new ServiceCollection();
                services.AddLogging(configure =>
                {
                    configure.SetMinimumLevel(LogLevel.Trace);
                    configure.AddConsole(loggerOptions => loggerOptions.IncludeScopes = true);
                });

                using var serviceProvider = services.BuildServiceProvider();
                var loggerFactory         = serviceProvider.GetRequiredService <ILoggerFactory>();

                using var httpEventListener = new HttpEventSourceListener(loggerFactory);

                var interopClient = new InteropClient(options, loggerFactory);
                await interopClient.Run();
            });

            return(await rootCommand.InvokeAsync(args));
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Application started.");

            var runtimeVersion = typeof(object).Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "Unknown";

            Console.WriteLine($"NetCoreAppVersion: {runtimeVersion}");

            InteropClient.Run(args);
        }
Exemplo n.º 4
0
        public static void Run(string[] args)
        {
            GrpcEnvironment.SetLogger(new ConsoleLogger());
            var parserResult = Parser.Default.ParseArguments <ClientOptions>(args)
                               .WithNotParsed(errors => Environment.Exit(1))
                               .WithParsed(options =>
            {
                Console.WriteLine("Use TLS: " + options.UseTls);
                Console.WriteLine("Server host: " + options.ServerHost);
                Console.WriteLine("Server port: " + options.ServerPort);

                var interopClient = new InteropClient(options);
                interopClient.Run().Wait();
            });
        }
Exemplo n.º 5
0
        public static async Task <int> Main(string[] args)
        {
            var rootCommand = new RootCommand();

            rootCommand.AddOption(new Option <string>(new string[] { "--client_type", nameof(ClientOptions.ClientType) }, () => "httpclient"));
            rootCommand.AddOption(new Option <string>(new string[] { "--server_host", nameof(ClientOptions.ServerHost) })
            {
                Required = true
            });
            rootCommand.AddOption(new Option <string>(new string[] { "--server_host_override", nameof(ClientOptions.ServerHostOverride) }));
            rootCommand.AddOption(new Option <int>(new string[] { "--server_port", nameof(ClientOptions.ServerPort) })
            {
                Required = true
            });
            rootCommand.AddOption(new Option <string>(new string[] { "--test_case", nameof(ClientOptions.TestCase) })
            {
                Required = true
            });
            rootCommand.AddOption(new Option <bool>(new string[] { "--use_tls", nameof(ClientOptions.UseTls) }));
            rootCommand.AddOption(new Option <bool>(new string[] { "--use_test_ca", nameof(ClientOptions.UseTestCa) }));
            rootCommand.AddOption(new Option <string>(new string[] { "--default_service_account", nameof(ClientOptions.DefaultServiceAccount) }));
            rootCommand.AddOption(new Option <string>(new string[] { "--oauth_scope", nameof(ClientOptions.OAuthScope) }));
            rootCommand.AddOption(new Option <string>(new string[] { "--service_account_key_file", nameof(ClientOptions.ServiceAccountKeyFile) }));
            rootCommand.AddOption(new Option <string>(new string[] { "--grpc_web_mode", nameof(ClientOptions.GrpcWebMode) }));

            rootCommand.Handler = CommandHandler.Create <ClientOptions>(async(options) =>
            {
                Console.WriteLine("Use TLS: " + options.UseTls);
                Console.WriteLine("Use Test CA: " + options.UseTestCa);
                Console.WriteLine("Client type: " + options.ClientType);
                Console.WriteLine("Server host: " + options.ServerHost);
                Console.WriteLine("Server port: " + options.ServerPort);

                var services = new ServiceCollection();
                services.AddLogging(configure =>
                {
                    configure.SetMinimumLevel(LogLevel.Trace);
                    configure.AddConsole(loggerOptions => loggerOptions.IncludeScopes = true);
                });

                using var serviceProvider = services.BuildServiceProvider();

                var interopClient = new InteropClient(options, serviceProvider.GetRequiredService <ILoggerFactory>());
                await interopClient.Run();
            });

            return(await rootCommand.InvokeAsync(args));
        }
Exemplo n.º 6
0
        public static void Run(string[] args)
        {
            var parserResult = Parser.Default.ParseArguments <ClientOptions>(args)
                               .WithNotParsed(errors => Environment.Exit(1))
                               .WithParsed(options =>
            {
                Console.WriteLine("Use TLS: " + options.UseTls);
                Console.WriteLine("Use Test CA: " + options.UseTestCa);
                Console.WriteLine("Client type: " + options.ClientType);
                Console.WriteLine("Server host: " + options.ServerHost);
                Console.WriteLine("Server port: " + options.ServerPort);

                using (var interopClient = new InteropClient(options))
                {
                    interopClient.Run().GetAwaiter().GetResult();
                }
            });
        }
Exemplo n.º 7
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Application started.");

            InteropClient.Run(args);
        }