diff --git a/TeachingRecordSystem/Directory.Packages.props b/TeachingRecordSystem/Directory.Packages.props
index 777b8f931d..46a8aeffa9 100644
--- a/TeachingRecordSystem/Directory.Packages.props
+++ b/TeachingRecordSystem/Directory.Packages.props
@@ -9,7 +9,7 @@
-
+
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Extensions.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Extensions.cs
index b631fb3b2f..f65c0f7156 100644
--- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Extensions.cs
+++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Extensions.cs
@@ -5,11 +5,8 @@
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Formatters;
-using OneOf;
-using Optional;
using TeachingRecordSystem.Api.Infrastructure.ApplicationModel;
using TeachingRecordSystem.Api.Infrastructure.Filters;
-using TeachingRecordSystem.Api.Infrastructure.Mapping;
using TeachingRecordSystem.Api.Infrastructure.ModelBinding;
using TeachingRecordSystem.Api.Infrastructure.OpenApi;
using TeachingRecordSystem.Api.Infrastructure.RateLimiting;
@@ -47,14 +44,6 @@ public static IHostApplicationBuilder AddApiServices(this IHostApplicationBuilde
public static IServiceCollection AddApiServices(this IServiceCollection services, IConfiguration configuration, IHostEnvironment environment)
{
- services.Scan(scan =>
- {
- scan.FromAssemblies(typeof(Extensions).Assembly)
- .AddClasses(filter => filter.AssignableTo(typeof(ITypeConverter<,>)))
- .AsSelf()
- .WithTransientLifetime();
- });
-
services
.AddMvc(options =>
{
@@ -132,7 +121,7 @@ public static IServiceCollection AddApiServices(this IServiceCollection services
.AddWebhookOptions(configuration)
.AddOpenApi(configuration)
.AddFluentValidation()
- .AddAutoMapper()
+ .AddApiMappers()
.AddHttpContextAccessor()
.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining())
.AddSingleton()
@@ -156,16 +145,21 @@ public static IServiceCollection AddApiServices(this IServiceCollection services
return services;
}
- private static IServiceCollection AddAutoMapper(this IServiceCollection services)
+ private static IServiceCollection AddApiMappers(this IServiceCollection services)
{
- services.AddAutoMapper(cfg =>
- {
- cfg.AddMaps(typeof(Program).Assembly);
- cfg.CreateMap(typeof(Option<>), typeof(Option<>)).ConvertUsing(typeof(OptionToOptionTypeConverter<,>));
- cfg.CreateMap(typeof(OneOf<,>), typeof(OneOf<,>)).ConvertUsing(typeof(OneOfToOneOfTypeConverter<,,,>));
- })
- .AddTransient(typeof(WrapWithOptionValueConverter<>))
- .AddTransient(typeof(WrapWithOptionValueConverter<,>));
+ services
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton();
return services;
}
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/GlobalUsings.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/GlobalUsings.cs
index 80de4427a0..634d42c715 100644
--- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/GlobalUsings.cs
+++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/GlobalUsings.cs
@@ -1,3 +1,2 @@
-global using AutoMapper;
global using TeachingRecordSystem.Core.ApiSchema;
global using PostgresModels = TeachingRecordSystem.Core.DataStore.Postgres.Models;
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/Mapping/OptionMapper.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/Mapping/OptionMapper.cs
deleted file mode 100644
index 5c88122a11..0000000000
--- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/Mapping/OptionMapper.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using OneOf;
-using Optional;
-
-namespace TeachingRecordSystem.Api.Infrastructure.Mapping;
-
-public class OptionToOptionTypeConverter : ITypeConverter