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
5 changes: 3 additions & 2 deletions MobileConfiguration/MobileConfiguration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.2" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.5.0" />
<PackageReference Include="Shared" Version="2025.7.10" />
<PackageReference Include="Shared.Results.Web" Version="2025.7.10" />
<PackageReference Include="Shared" Version="2025.7.13" />
<PackageReference Include="Shared.Logger" Version="2025.7.13" />
<PackageReference Include="Shared.Results.Web" Version="2025.7.13" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.5">
Expand Down
7 changes: 6 additions & 1 deletion MobileConfiguration/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Shared.Middleware;
using Shared.Repositories;
using System.Reflection;
using Shared.Logger.TennantContext;
using ILogger = Microsoft.Extensions.Logging.ILogger;

IConfigurationRoot configuration = new ConfigurationBuilder()
Expand All @@ -25,17 +26,19 @@
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Host.UseWindowsService();
String path = Assembly.GetExecutingAssembly().Location;
path = Path.GetDirectoryName(path);

Check warning on line 29 in MobileConfiguration/Program.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Converting null literal or possible null value to non-nullable type.
builder.Configuration.SetBasePath(path)

Check warning on line 30 in MobileConfiguration/Program.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Possible null reference argument for parameter 'basePath' in 'IConfigurationBuilder FileConfigurationExtensions.SetBasePath(IConfigurationBuilder builder, string basePath)'.
.AddJsonFile("hosting.json", optional: true)
.AddJsonFile("hosting.development.json", optional: true)
.AddEnvironmentVariables();
// Add services to the container.

builder.Services.AddHttpContextAccessor();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddScoped<TenantContext>();
builder.Services.AddSingleton<IConfigurationRepository, ConfigurationRepository>();
builder.Services.AddSingleton(typeof(IDbContextResolver<>), typeof(DbContextResolver<>));
Boolean isInMemoryDatabase = Boolean.Parse(ConfigurationReader.GetValue("AppSettings", "InMemoryDatabase"));
Expand All @@ -61,6 +64,8 @@

String nlogConfigFilename = "nlog.config";

app.UseMiddleware<TenantMiddleware>();

if (app.Environment.IsDevelopment())
{
var developmentNlogConfigFilename = "nlog.development.config";
Expand All @@ -75,8 +80,8 @@

var loggerFactory = app.Services.GetRequiredService<ILoggerFactory>();

loggerFactory.ConfigureNLog(Path.Combine(path, nlogConfigFilename));

Check warning on line 83 in MobileConfiguration/Program.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

'ConfigureExtensions.ConfigureNLog(ILoggerFactory, string)' is obsolete: 'Instead use NLog.LogManager.Setup().LoadConfigurationFromFile()'
loggerFactory.AddNLog();

Check warning on line 84 in MobileConfiguration/Program.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

'ConfigureExtensions.AddNLog(ILoggerFactory)' is obsolete: 'Instead use ILoggingBuilder.AddNLog() or IHostBuilder.UseNLog()'

ILogger logger = loggerFactory.CreateLogger("MobileConfiguration");

Expand All @@ -85,7 +90,7 @@

// Configure the HTTP request pipeline.
app.UseAuthorization();
app.UseMiddleware<TenantMiddleware>();

app.AddRequestLogging();
app.AddResponseLogging();
app.AddExceptionHandler();
Expand All @@ -100,7 +105,7 @@

async Task InitializeDatabase(IApplicationBuilder app)
{
using (IServiceScope serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())

Check warning on line 108 in MobileConfiguration/Program.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Dereference of a possibly null reference.
{
ConfigurationContext dbContext = serviceScope.ServiceProvider.GetRequiredService<ConfigurationContext>();

Expand All @@ -124,7 +129,7 @@

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

Check warning on line 132 in MobileConfiguration/Program.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The variable 'kex' is declared but never used
return defaultValue;
}
}
Expand Down
Loading