Пример #1
0
        public static IRhetosHostBuilder CreateRhetosHostBuilder()
        {
            var host          = CreateHostBuilder(null).Build();
            var configuration = host.Services.GetRequiredService <IConfiguration>();

            var rhetosHostBuilder = new RhetosHostBuilder();

            Startup.ConfigureRhetosHostBuilder(rhetosHostBuilder, configuration);

            return(rhetosHostBuilder);
        }
Пример #2
0
        public static RhetosAspNetServiceCollectionBuilder AddRhetos(this IServiceCollection serviceCollection, Action <IRhetosHostBuilder> configureRhetosHost = null)
        {
            var rhetosHostBuilder = new RhetosHostBuilder();

            configureRhetosHost?.Invoke(rhetosHostBuilder);
            var rhetosHost = rhetosHostBuilder.Build();

            serviceCollection.AddSingleton(rhetosHost);
            serviceCollection.AddScoped <RhetosScopeServiceProvider>();
            serviceCollection.AddScoped(typeof(IRhetosComponent <>), typeof(RhetosComponent <>));

            return(new RhetosAspNetServiceCollectionBuilder(serviceCollection, rhetosHost));
        }
Пример #3
0
        // This method exposes IRhetosHostBuilder for purposes of tooling using same configuration values
        // and same RhetosHostBuilder configuration delegate as the app itself
        public static IRhetosHostBuilder CreateRhetosHostBuilder()
        {
            // create Host for this web app
            var host = CreateHostBuilder(null).Build();

            // extract configuration of the web app
            var configuration = host.Services.GetRequiredService <IConfiguration>();

            // Create RhetosHostBuilder and configure it
            var rhetosHostBuilder = new RhetosHostBuilder();

            Startup.ConfigureRhetosHostBuilder(rhetosHostBuilder, configuration);

            return(rhetosHostBuilder);
        }
Пример #4
0
        // Method by convention. Any Rhetos tooling (e.g. dbupdate) will look for this method in current application
        // to create host for all its operations.
        public static IRhetosHostBuilder CreateRhetosHostBuilder()
        {
            var configuration = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
                                .AddJsonFile("console-app-settings.json")
                                .AddJsonFile("console-app-settings.local.json")
                                .Build();

            var rhetosHostBuilder = new RhetosHostBuilder()
                                    .ConfigureRhetosHostDefaults()
                                    .ConfigureConfiguration(builder => builder.MapNetCoreConfiguration(configuration))
                                    .ConfigureContainer(builder =>
            {
                builder.UseUserInfoProvider(() => new ProcessUserInfo());
            });

            return(rhetosHostBuilder);
        }