private static IServiceCollection AddAcroServices(this IServiceCollection services, AcroClientBuilder clientbuilder, AcroInputBuilder inputbuilder, AcroOutputBuilder outputbuilder) { services.AddSingleton <IAcroInput>(inputbuilder.Build()); services.AddHostedService <AcroInput>(sp => sp.GetRequiredService <IAcroInput>() as AcroInput); services.AddSingleton <IAcroOutput>(outputbuilder.Build()); services.AddHostedService <AcroOutput>(sp => sp.GetRequiredService <IAcroOutput>() as AcroOutput); services.AddSingleton <IAcroClient>(sp => { var input = sp.GetRequiredService <IAcroInput>(); var output = sp.GetRequiredService <IAcroOutput>(); clientbuilder.AddInput(input); clientbuilder.AddOutput(output); return(clientbuilder.Build()); }); return(services); }