Skip to content

Commit 2c5dbb9

Browse files
committed
Update for newer .net runtime
1 parent 293a493 commit 2c5dbb9

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/OpenRCT2.API/Startup.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ public class Startup
3030

3131
public IConfiguration Configuration { get; }
3232
public IWebHostEnvironment HostingEnvironment { get; }
33-
public ILogger Logger { get; }
3433

35-
public Startup(IConfiguration configuration, IWebHostEnvironment env, ILoggerFactory loggerFactory)
34+
public Startup(IConfiguration configuration, IWebHostEnvironment env)
3635
{
3736
Configuration = configuration;
3837
HostingEnvironment = env;
39-
Logger = loggerFactory.CreateLogger<Startup>();
4038
}
4139

4240
public void ConfigureServices(IServiceCollection services)
@@ -54,9 +52,9 @@ public void ConfigureServices(IServiceCollection services)
5452
services.AddSingleton<ILocalisationService, LocalisationService>();
5553
services.AddSingleton<Emailer>();
5654
services.AddSingleton<GoogleRecaptchaService>();
57-
services.AddSingleton<NeDesignsService>();
58-
services.AddSingleton<UserAccountService>();
59-
services.AddSingleton<UserAuthenticationService>();
55+
services.AddScoped<NeDesignsService>();
56+
services.AddScoped<UserAccountService>();
57+
services.AddScoped<UserAuthenticationService>();
6058

6159
if (!HostingEnvironment.IsTesting())
6260
{
@@ -81,7 +79,8 @@ public void Configure(
8179
IServiceProvider serviceProvider,
8280
IApplicationBuilder app,
8381
IWebHostEnvironment env,
84-
IOptions<DBOptions> dbOptions)
82+
IOptions<DBOptions> dbOptions,
83+
ILogger<Startup> logger)
8584
{
8685
// Use X-Forwarded-For header for client IP address
8786
app.UseForwardedHeaders(
@@ -98,7 +97,7 @@ public void Configure(
9897
// Setup / connect to the database
9998
if (dbOptions.Value.Host == null)
10099
{
101-
Logger.LogWarning("No database has been configured");
100+
logger.LogWarning("No database has been configured");
102101
}
103102
else
104103
{
@@ -111,7 +110,7 @@ public void Configure(
111110
}
112111
catch (Exception ex)
113112
{
114-
Logger.LogError(ex, "An error occured while setting up the database service");
113+
logger.LogError(ex, "An error occured while setting up the database service");
115114
}
116115
}
117116

0 commit comments

Comments
 (0)