示例#1
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);
        }
        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);
        }
示例#3
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>());
        }