public IHostBuilder InitializeServices(IHostBuilder hostBuilder) { hostBuilder.ConfigureServices( (_, services) => services .AddScoped <IShellArgsOptionBuilder, ShellArgsOptionBuilder>() .AddScoped <IShellBootstrap, ShellBootstrap>() .AddScoped <ICommandLineProcessor, CommandLineProcessor>() .AddScoped <IServiceProviderScope, ServiceProviderScope>( serviceProvider => new ServiceProviderScope(ScopedServiceProvider) ) .AddScoped <ICommandsAlias, CommandsAlias>() .AddScoped <IModuleSet, ModuleSet>() .AddScoped <ICommandBatchProcessor, CommandBatchProcessor>() .AddScoped <ISyntaxAnalyser, SyntaxAnalyser>() .AddScoped <IModuleManager, ModuleManager>() .AddScoped <IModuleCommandManager, ModuleCommandManager>() .AddScoped <IHookManager, HookManager>() .AddScoped <IExternalParserExtension, CommandLineProcessorExternalParserExtension>() .AddScoped <ICommandLineReader, CommandLineReader>( serviceProvider => { var clr = new CommandLineReader(); clr.Initialize( null, serviceProvider.GetRequiredService <ICommandLineProcessor>()); return(clr); }) .AddScoped <IShellServiceHost, ShellServiceHost>() ); return(hostBuilder); }