Ejemplo n.º 1
0
 public static IConsoleAppBuilder <T> UseEnvironment <T>(this IConsoleAppBuilder <T> hostBuilder, string environment)
     where T : class
 {
     return(hostBuilder.ConfigureApp(configBuilder =>
     {
         configBuilder.AddInMemoryCollection(new[]
         {
             new KeyValuePair <string, string>(HostDefaults.EnvironmentKey,
                                               environment ?? throw new ArgumentNullException(nameof(environment)))
         });
        public static IConsoleAppBuilder UseStartup <TStartup>(this IConsoleAppBuilder hostBuilder)
            where TStartup : IConsoleStartup, new()
        {
            Type startupType         = typeof(TStartup);
            var  startupAssemblyName = startupType.GetTypeInfo().Assembly.GetName().Name;

            return(hostBuilder
                   .UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName)
                   .ConfigureServices((services) =>
            {
                hostBuilder.Startup = new TStartup();
                hostBuilder.Startup.Environment = hostBuilder.Environment;
                hostBuilder.Startup.Configuration = hostBuilder.Configuration;

                hostBuilder.Startup.ConfigureServices(services);
                services.AddSingleton(typeof(IConsoleStartup), sp =>
                {
                    hostBuilder.Startup.Configure(sp);
                    return hostBuilder.Startup;
                });
            }));
        }
Ejemplo n.º 3
0
 public static IConsoleAppBuilder <T> ConfigureLogging <T>(this IConsoleAppBuilder <T> builder, Action <ILoggingBuilder> configureLogging)
     where T : class
 {
     return(builder.ConfigureServices((config, env, collection) => collection.AddLogging(builder => configureLogging(builder))));
 }