public void Run <TStartup>() where TStartup : Startup, new()
        {
            var instance = new TStartup();

            DependencyInjection.Resolve(serviceProvider, instance);
            instance.Run(args);
        }
Example #2
0
        public ServiceResolverBuilder UseStartup <TStartup>() where TStartup : IServiceResolverStartup, new()
        {
            var startup = new TStartup();

            configurationActions.Add(config => startup.Configure(config));
            configureServicesActions.Add((config, services) => startup.ConfigureServices(config, services));
            return(this);
        }
        public WebHost UseStartup <TStartup>() where TStartup : IStartup, new()
        {
            var startup             = new TStartup();
            var serviceConfigurator = compositionRoot.ServiceConfigurator;

            startup.ConfigureServices(serviceConfigurator);
            requestListener.Configuration = startup.Configuration;
            return(this);
        }
Example #4
0
        public IHost Build <TStartup>() where TStartup : IStartup, new()
        {
            IStartup startup = new TStartup();

            ConfigureMembers(startup.Members);
            IServiceCollection hostingServices = BuildHostingServices();

            startup.ConfigureServices(hostingServices);
            IServiceProvider hostingContainer = startup.ConfigureServices(hostingServices);

            return(new TinkerHost(hostingServices, hostingContainer, members));
        }
        private static ActorSystem StartInternal <TStartup>()
            where TStartup : MicroserviceStartup, new()
        {
            var startup = new TStartup();

            startup.Configure();

            var config = startup.ConfigureActorSystem();

            var system = ActorSystem.Create(startup.ActorSystemName(config), config);

            startup.StartActors(system);

            return(system);
        }
Example #6
0
        /// <summary>
        /// Configures a new inversion-of-control container from the provided <see cref="IStartup"/>.
        /// </summary>
        /// <typeparam name="TStartup"></typeparam>
        public static TApp Init <TApp, TStartup>()
            where TApp : Application
            where TStartup : IStartup, new()
        {
            StartupAssembly = Assembly.GetAssembly(typeof(TStartup));
            var startup       = new TStartup();
            var configBuilder = new ConfigurationBuilder();

            startup.Configure(configBuilder);
            _config = configBuilder.Build();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <TApp>();
            startup.RegisterDependencies(serviceCollection, _config);
            _sp     = serviceCollection.BuildServiceProvider();
            _scopes = new Dictionary <string, IServiceScope>();

            return(Resolve <TApp>());
        }