Beispiel #1
0
        private static OneCSharpSettings OneCSharpSettings()
        {
            OneCSharpSettings settings = new OneCSharpSettings();
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json", optional: false)
                         .Build();

            config.GetSection("OneCSharpSettings").Bind(settings);
            return(settings);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            OneCSharpSettings settings = OneCSharpSettings();

            var host = CreateHostBuilder(args).Build();

            using (var serviceScope = host.Services.CreateScope())
            {
                var services = serviceScope.ServiceProvider;
                try
                {
                    var env      = services.GetRequiredService <IWebHostEnvironment>();
                    var metadata = services.GetRequiredService <IMetadataService>();
                    ConfigureMetadataService(metadata, settings.MetadataSettings, env);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred.");
                }
            }

            host.Run();
        }