26 lines
1.1 KiB
C#
26 lines
1.1 KiB
C#
using NeonSprawl.Server.Game.PositionState;
|
|
|
|
namespace NeonSprawl.Server.Game.Contracts;
|
|
|
|
/// <summary>Registers contract instance + outcome persistence (NEO-146).</summary>
|
|
public static class ContractInstanceServiceCollectionExtensions
|
|
{
|
|
/// <summary>PostgreSQL when <c>ConnectionStrings:NeonSprawl</c> is set; otherwise in-memory fallback.</summary>
|
|
public static IServiceCollection AddContractInstanceStores(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
var cs = configuration.GetConnectionString(PositionStateServiceCollectionExtensions.NeonSprawlConnectionStringName);
|
|
if (!string.IsNullOrWhiteSpace(cs))
|
|
{
|
|
services.AddSingleton<IContractInstanceStore, PostgresContractInstanceStore>();
|
|
services.AddSingleton<IContractOutcomeStore, PostgresContractOutcomeStore>();
|
|
}
|
|
else
|
|
{
|
|
services.AddSingleton<IContractInstanceStore, InMemoryContractInstanceStore>();
|
|
services.AddSingleton<IContractOutcomeStore, InMemoryContractOutcomeStore>();
|
|
}
|
|
|
|
return services;
|
|
}
|
|
}
|