Exemplo n.º 1
0
        public static async Task Main(string[] args)
        {
            CommandLineParameters parameters = CommandLineParameters.Parse(args);

            IHost host = CreateHostBuilder(args, parameters).Build();

            IPathService pathService = host.Services.GetService <IPathService>();

            pathService.WorkingDirectory = parameters.WorkingDir;

            IServiceManager serviceManager = host.Services.GetService <IServiceManager>();

            await host.RunAsync(serviceManager.CancellationToken);
        }
Exemplo n.º 2
0
        // Additional configuration is required to successfully run gRPC on macOS.
        // For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
        public static IHostBuilder CreateHostBuilder(string[] args, CommandLineParameters parameters)
        {
            return(Host.CreateDefaultBuilder(args)
                   .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.ConfigureKestrel(options =>
                {
                    if (parameters.HasPort)
                    {
                        // Setup a HTTP/2 endpoint without TLS.
                        options.ListenLocalhost(int.Parse(parameters.Port), o => o.Protocols = HttpProtocols.Http2);
                    }
                });

                webBuilder.UseStartup <Startup>();
            }));
        }
Exemplo n.º 3
0
        public static CommandLineParameters Parse(string[] arguments)
        {
            CommandLineParameters parameters = new CommandLineParameters();

            foreach (string argument in arguments)
            {
                string[] parts = argument.Split('=', StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length == 2)
                {
                    switch (parts[0])
                    {
                    case "--port":
                        parameters.Port = parts[1];
                        break;

                    case "--workingDir":
                        parameters.WorkingDir = ParseStringParameterValue(parts[1]);
                        break;
                    }
                }
            }

            return(parameters);
        }