namespace SOR.Shared; using Microsoft.Extensions.DependencyInjection; using SOR.Networking.Abstractions.Messaging; using SOR.Shared.Serialization; /// /// Registers SOR.Shared services into the DI container. /// Called once in SOR.Host.Program.cs before any other service registration. /// public static class ServiceRegistration { /// /// Registers all shared infrastructure services: /// - IMessageSerializer (SystemTextJsonSerializer by default) /// /// To swap the serializer to MessagePack, replace this registration in Program.cs: /// builder.Services.AddSingleton{IMessageSerializer, MessagePackSerializer}() /// after calling AddSharedServices(), which will override the default. /// public static IServiceCollection AddSharedServices(this IServiceCollection services) { // Singleton: one serializer instance for the process lifetime. // SystemTextJsonSerializer has no mutable state — safe to share across threads. services.AddSingleton(); return services; } }