public static TService UseStartupAndBuildWithDerbyConfiguration <TService, TStartup>(this IServiceBuilder <TService> serviceBuilder)
            where TStartup : class, IStartup
        {
            ServiceProvider GetConfigurationConfigurationServiceProvider()
            {
                var configurationConfigurationServiceProvider = ServiceProviderServiceBuilder.New()
                                                                .UseStartupAndBuild <ApplicationConfigurationConfigurationStartup>()
                ;

                return(configurationConfigurationServiceProvider);
            }

            ServiceProvider GetConfigurationServiceProvider()
            {
                var configurationServiceProvider = ServiceProviderServiceBuilder.New()
                                                   .UseStartupAndBuild <ApplicationConfigurationStartup>(GetConfigurationConfigurationServiceProvider)
                ;

                return(configurationServiceProvider);
            }

            TService GetService()
            {
                var service = serviceBuilder.UseStartupAndBuild <TService, TStartup>(GetConfigurationServiceProvider);

                return(service);
            }

            var output = GetService();

            return(output);
        }
Ejemplo n.º 2
0
 public static ServiceProvider GetServiceProvider()
 {
     using (var configurationConfigurationServiceProvider = ServiceProviderServiceBuilder.New().UseStartupAndBuild <DefaultStartupConfigurationConfiguration>())
     {
         var configurationServiceProvider = ServiceProviderServiceBuilder.New().UseStartupAndBuild <DefaultStartupConfiguration>(configurationConfigurationServiceProvider);
         return(configurationServiceProvider);
     }
 }
Ejemplo n.º 3
0
        private static void ServiceProviderExample()
        {
            var emptyServiceProvider = ServiceProviderHelper.GetNewEmptyServiceProvider();

            var serviceProvider = ServiceProviderServiceBuilder.New()
                                  .UseStartup <Startup>()
                                  .Build(emptyServiceProvider);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            using (var serviceProvider = ServiceProviderServiceBuilder.New().UseStartupAndBuild <Startup>())
            {
                var program = serviceProvider.GetRequiredService <Program>();

                program.Run();
            }
        }
Ejemplo n.º 5
0
        public static async Task RunAsync <TProgram, TStartup>(this IProgramAsService programAsService)
            where TProgram : AsynchronousProgramAsServiceBase
            where TStartup : StartupBase
        {
            var configurationConfigurationServiceProvider = ServiceProviderServiceBuilder.New().UseStartupAndBuild <DefaultStartupConfigurationConfiguration>();
            var configurationServiceProvider = ServiceProviderServiceBuilder.New().UseStartupAndBuild <DefaultStartupConfiguration>(configurationConfigurationServiceProvider);

            await ProgramAsService.RunAsync <TProgram, TStartup>(configurationServiceProvider);
        }
        public TDbContext CreateDbContext(string[] args)
        {
            var emptyServiceProvider = ServiceProviderHelper.GetNewEmptyServiceProvider();

            var serviceProvider = ServiceProviderServiceBuilder.New()
                                  .UseStartup <TDesignTimeDbContextFactoryStartup>()
                                  .Build(emptyServiceProvider);

            var dbContext = serviceProvider.GetRequiredService <TDbContext>();

            return(dbContext);
        }
        public static TService UseStartupAndBuild <TService, TStartup, TConfigurationStartup>(this IServiceBuilder <TService> serviceBuilder, IServiceProvider configurationConfigurationServiceProvider)
            where TStartup : class, IStartup
            where TConfigurationStartup : class, IStartup
        {
            // Get the configuration service provider.
            var configurationServiceProvider = ServiceProviderServiceBuilder.New()
                                               .UseStartupAndBuild <ServiceProvider, TConfigurationStartup>(configurationConfigurationServiceProvider)
            ;

            // Use the configuration service provider.
            var service = serviceBuilder.UseStartupAndBuild <TService, TStartup>(configurationServiceProvider);

            return(service);
        }
Ejemplo n.º 8
0
        public static async Task RunAsync <TAsynchronousProgramAsService, TStartup>(IServiceProvider configurationServiceProvider)
            where TAsynchronousProgramAsService : AsynchronousProgramAsServiceBase
            where TStartup : class, IStartup
        {
            var serviceProvider = ServiceProviderServiceBuilder.New()
                                  .AddAsynchronousProgramAsService <ServiceProvider, TAsynchronousProgramAsService>()
                                  .UseStartup <ServiceProvider, TStartup>()
                                  .Build(configurationServiceProvider);

            using (serviceProvider)
            {
                var program = serviceProvider.GetRequiredService <TAsynchronousProgramAsService>();

                await program.SubMainAsync();
            }
        }
Ejemplo n.º 9
0
        public static void Run <TProgramAsService, TStartup>(IServiceProvider configurationServiceProvider)
            where TProgramAsService : ProgramAsServiceBase
            where TStartup : class, IStartup
        {
            var serviceProvider = ServiceProviderServiceBuilder.New()
                                  .AddProgramAsService <ServiceProvider, TProgramAsService>()
                                  .UseStartup <ServiceProvider, TStartup>()
                                  .Build(configurationServiceProvider);

            using (serviceProvider)
            {
                var program = serviceProvider.GetRequiredService <TProgramAsService>();

                program.SubMain();
            }
        }