neon-sprawl/server/NeonSprawl.Server/Game/Items/PlayerInventoryServiceColle...

23 lines
841 B
C#

using NeonSprawl.Server.Game.PositionState;
namespace NeonSprawl.Server.Game.Items;
/// <summary>Registers inventory persistence: PostgreSQL when configured, otherwise in-memory fallback (NEO-54).</summary>
public static class PlayerInventoryServiceCollectionExtensions
{
public static IServiceCollection AddPlayerInventoryStore(this IServiceCollection services, IConfiguration configuration)
{
var cs = configuration.GetConnectionString(PositionStateServiceCollectionExtensions.NeonSprawlConnectionStringName);
if (!string.IsNullOrWhiteSpace(cs))
{
services.AddSingleton<IPlayerInventoryStore, PostgresPlayerInventoryStore>();
}
else
{
services.AddSingleton<IPlayerInventoryStore, InMemoryPlayerInventoryStore>();
}
return services;
}
}