Пример #1
0
        protected static void InitPlatform(IStartup startup = null, Action <IServiceCollection> platformBuild = null)
        {
            var services = new ServiceCollection();

            // add standard infrastructure
            services.AddSingleton <IMessageBus, MessageBus>();

            startup?.ConfigureServices(services);
            platformBuild?.Invoke(services);
            Services = services;

            container = startup?.CreateServiceProvider(services) ?? services.BuildServiceProvider();
            startup?.ConfigureApp(container);

            container.RunPostBuildActions();
            var tasks = container.GetServices <IStartupTask>();

            foreach (var task in tasks)
            {
                task.Start();
            }
        }