Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions MobileConfiguration/MobileConfiguration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageReference Include="NLog.Web.AspNetCore" Version="6.1.1" />
<PackageReference Include="Shared" Version="2026.2.1" />
<PackageReference Include="Shared.Logger" Version="2026.2.1" />
<PackageReference Include="Shared.Results.Web" Version="2026.2.1" />
<PackageReference Include="Shared" Version="2026.2.2" />
<PackageReference Include="Shared.Logger" Version="2026.2.2" />
<PackageReference Include="Shared.Results.Web" Version="2026.2.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.3">
Expand Down
25 changes: 3 additions & 22 deletions MobileConfiguration/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
builder.Services.AddDbContext<ConfigurationContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("ConfigurationDatabase")));
}
bool logRequests = ConfigurationReaderExtensions.GetValueOrDefault<Boolean>("MiddlewareLogging", "LogRequests", true);
bool logResponses = ConfigurationReaderExtensions.GetValueOrDefault<Boolean>("MiddlewareLogging", "LogResponses", true);
LogLevel middlewareLogLevel = ConfigurationReaderExtensions.GetValueOrDefault("MiddlewareLogging", "MiddlewareLogLevel", LogLevel.Warning);
bool logRequests = ConfigurationReader.GetValueOrDefault<Boolean>("MiddlewareLogging", "LogRequests", true);
bool logResponses = ConfigurationReader.GetValueOrDefault<Boolean>("MiddlewareLogging", "LogResponses", true);
LogLevel middlewareLogLevel = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "MiddlewareLogLevel", LogLevel.Warning);

RequestResponseMiddlewareLoggingConfig config = new(middlewareLogLevel, logRequests, logResponses);

Expand Down Expand Up @@ -132,23 +132,4 @@ async Task InitializeDatabase(IApplicationBuilder app)
await dbContext.MigrateAsync(CancellationToken.None);
}
}
}

public static class ConfigurationReaderExtensions {
public static T GetValueOrDefault<T>(String sectionName,
String keyName,
T defaultValue) {
try {
var value = ConfigurationReader.GetValue(sectionName, keyName);

if (String.IsNullOrEmpty(value)) {
return defaultValue;
}

return (T)Convert.ChangeType(value, typeof(T));
}
catch (KeyNotFoundException kex) {
return defaultValue;
}
}
}
Loading