/// <summary>
        /// Configures the services.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="services">The services.</param>
        public void ConfigureServices(HostBuilderContext context, IServiceCollection services)
        {
            var rocketHostBuilder = RocketHostExtensions.GetConventionalHostBuilder(_hostBuilder);

            services.AddSingleton(rocketHostBuilder.AssemblyCandidateFinder);
            services.AddSingleton(rocketHostBuilder.AssemblyProvider);
            services.AddSingleton(rocketHostBuilder.Scanner);
#if !(NETSTANDARD2_0 || NETCOREAPP2_1)
            services.AddHealthChecks();
#endif
        }
        /// <summary>
        /// Configures the application configuration.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="configurationBuilder">The configuration builder.</param>
        public void ConfigureAppConfiguration(HostBuilderContext context, IConfigurationBuilder configurationBuilder)
        {
            var rocketHostBuilder = RocketHostExtensions.GetConventionalHostBuilder(_hostBuilder);

            InsertConfigurationSourceAfter(
                configurationBuilder.Sources,
                sources => sources.OfType <JsonConfigurationSource>().FirstOrDefault(x => x.Path == "appsettings.json"),
                (source) => new YamlConfigurationSource()
            {
                Path           = "appsettings.yml",
                FileProvider   = source.FileProvider,
                Optional       = true,
                ReloadOnChange = true,
            });

            InsertConfigurationSourceAfter(
                configurationBuilder.Sources,
                sources => sources.OfType <JsonConfigurationSource>().FirstOrDefault(x =>
                                                                                     string.Equals(x.Path, $"appsettings.{context.HostingEnvironment.EnvironmentName}.json",
                                                                                                   StringComparison.OrdinalIgnoreCase)),
                (source) => new YamlConfigurationSource()
            {
                Path           = $"appsettings.{context.HostingEnvironment.EnvironmentName}.yml",
                FileProvider   = source.FileProvider,
                Optional       = true,
                ReloadOnChange = true,
            });

            var cb = new ConfigurationBuilder(
                rocketHostBuilder.Scanner,
                context.HostingEnvironment.Convert(),
                context.Configuration,
                configurationBuilder,
                rocketHostBuilder.Logger,
                rocketHostBuilder.Properties);

            cb.Build();

            MoveConfigurationSourceToEnd(configurationBuilder.Sources,
                                         sources => sources.OfType <JsonConfigurationSource>().Where(x =>
                                                                                                     string.Equals(x.Path, "secrets.json", StringComparison.OrdinalIgnoreCase)));

            MoveConfigurationSourceToEnd(configurationBuilder.Sources,
                                         sources => sources.OfType <EnvironmentVariablesConfigurationSource>());

            MoveConfigurationSourceToEnd(configurationBuilder.Sources,
                                         sources => sources.OfType <CommandLineConfigurationSource>());
        }
        /// <summary>
        /// Configures the cli.
        /// </summary>
        /// <param name="configurationBuilder">The configuration builder.</param>
        public void ConfigureCli(IConfigurationBuilder configurationBuilder)
        {
            var rocketHostBuilder = RocketHostExtensions.GetConventionalHostBuilder(_hostBuilder);
            var clb = new CommandLineBuilder(
                rocketHostBuilder.Scanner,
                rocketHostBuilder.AssemblyProvider,
                rocketHostBuilder.AssemblyCandidateFinder,
                rocketHostBuilder.Logger,
                rocketHostBuilder.Properties
                );

            _exec = clb.Build().Parse(_args ?? Array.Empty <string>());
            _args = _exec.ApplicationState.RemainingArguments ?? Array.Empty <string>();
            configurationBuilder.AddApplicationState(_exec.ApplicationState);
            rocketHostBuilder.Properties.Add(typeof(ICommandLineExecutor), _exec);
        }
        /// <summary>
        /// Defaults the services.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="services">The services.</param>
        public void DefaultServices(HostBuilderContext context, IServiceCollection services)
        {
            var conventionalBuilder = RocketHostExtensions.GetConventionalHostBuilder(_hostBuilder);

            _hostBuilder.UseServiceProviderFactory(
                new ServicesBuilderServiceProviderFactory(collection =>
                                                          new ServicesBuilder(
                                                              conventionalBuilder.Scanner,
                                                              conventionalBuilder.AssemblyProvider,
                                                              conventionalBuilder.AssemblyCandidateFinder,
                                                              collection,
                                                              context.Configuration,
                                                              context.HostingEnvironment.Convert(),
                                                              conventionalBuilder.Logger,
                                                              conventionalBuilder.Properties
                                                              )
                                                          )
                );
        }