コード例 #1
0
        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);
        }