Skip to content

Commit 8c7a190

Browse files
committed
TD-5930 Compensate for Azure not having different appsettings across multiple projects
1 parent b7452fb commit 8c7a190

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

LearningHub.Nhs.WebUI.BlazorClient/Program.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,15 @@
6060
// Candidates for DI collection
6161
builder.Services.AddSingleton<ITELBlazorBaseComponentConfiguration>(sp =>
6262
{
63+
var environment = builder.Configuration["Environment"];
64+
// Azure cant have differing application values so we default to assembly name if not set
65+
var application = builder.Configuration["Properties:Application"] ??
66+
typeof(Program).Assembly.GetName().Name;
67+
6368
return new TELBlazorBaseComponentConfiguration
6469
{
6570
JSEnabled = true, //if we are inject the client then it is true
66-
HostType = $"{builder.Configuration["Environment"]} {builder.Configuration["Properties:Application"]}"
71+
HostType = $"{environment} {application}",
6772
};
6873
});
6974

LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
namespace LearningHub.Nhs.WebUI.Startup
1+
using TELBlazor.Components.Core.Configuration;
2+
3+
namespace LearningHub.Nhs.WebUI.Startup
24
{
3-
using System;
4-
using System.Net.Http;
55
using Blazored.LocalStorage;
66
using GDS.MultiPageFormData;
77
using LearningHub.Nhs.Models.OpenAthens;
@@ -19,8 +19,11 @@
1919
using Microsoft.Extensions.Configuration;
2020
using Microsoft.Extensions.DependencyInjection;
2121
using Microsoft.Extensions.Hosting;
22+
using System;
23+
using System.Net.Http;
2224
using TELBlazor.Components.Core.Configuration;
2325
using TELBlazor.Components.Core.Services.HelperServices;
26+
using static System.Net.Mime.MediaTypeNames;
2427

2528
/// <summary>
2629
/// The service mappings.
@@ -156,6 +159,12 @@ public static void AddLearningHubMappings(this IServiceCollection services, ICon
156159
var context = httpContextAccessor.HttpContext;
157160
bool jsEnabled = false;
158161

162+
var environment = builder.Configuration["Environment"];
163+
164+
// Azure cant have differing application values so we default to assembly name if not set
165+
var application = builder.Configuration["Properties:Application"] ??
166+
typeof(Program).Assembly.GetName().Name;
167+
159168
if (context != null && context.Request.Cookies.TryGetValue("jsEnabled", out var jsCookieValue))
160169
{
161170
jsEnabled = jsCookieValue == "true";
@@ -164,11 +173,11 @@ public static void AddLearningHubMappings(this IServiceCollection services, ICon
164173
return new TELBlazorBaseComponentConfiguration
165174
{
166175
JSEnabled = jsEnabled,
167-
HostType = $"{configuration["Environment"]} {configuration["Properties:Application"]}",
176+
HostType = $"{environment} {application}",
168177
};
169178
});
170179

171180
services.AddScoped<ILogLevelSwitcherService, NLogLogLevelSwitcherService>();
172181
}
173182
}
174-
}
183+
}

0 commit comments

Comments
 (0)