Ejemplo n.º 1
0
 private static IHostBuilder ConfigureHost(this IHostBuilder builder, IConfigurationRoot configuration, Action <HostBuilderContext, IServiceCollection> nativeConfigureServices)
 {
     return(builder.UseContentRoot(FileSystem.AppDataDirectory) // Tell the host configuration where to file the file (this is required for Xamarin apps)
            .ConfigureHostConfiguration(builder => builder.AddConfiguration(configuration))
            .ConfigureAppConfiguration((hostContext, builder) => builder.AddConfiguration(configuration)).ConfigureServices((hostBuilderContext, services) =>
     {
         // Configure our local services and access the host configuration
         nativeConfigureServices(hostBuilderContext, services);
         ConfigureServices(hostBuilderContext, services);
     }));
 }
 public static IHostBuilder UseApplicationConfiguration(this IHostBuilder builder)
 {
     return(builder
            .ConfigureAppConfiguration((context, builder) =>
     {
         builder
         .AddConfiguration(context.Configuration)
         .Build();
     }));
 }
//-:cnd:noEmit
#endif
        //+:cnd:noEmit

        public static IHostBuilder AddAppSettings(this IHostBuilder hostBuilder)
        {
            if (hostBuilder is null)
            {
                throw new ArgumentNullException(nameof(hostBuilder));
            }

            return(hostBuilder
                   .AddConfiguration()
                   .ConfigureHostConfiguration(b => b
                                               .AddGeneralAppSettings()
                                               .AddEnvironmentAppSettings()
                                               ));
        }
Ejemplo n.º 4
0
 public static void ConfigureHost(IHostBuilder builder) =>
 builder
 .ConfigureAppConfiguration(builder =>
                            builder.AddConfiguration(Configuration.Base))
 .UseSerilog();