chomp 6e4c7abf73 dump-processor-cleanup (#6)
Co-authored-by: Alex <alex@dm-me-for-questions.com>
Reviewed-on: SPT-AKI/LootDumpProcessor#6
2024-04-16 18:29:40 +00:00

29 lines
888 B
C#

using LootDumpProcessor.Storage.Implementations.File.Handlers;
namespace LootDumpProcessor.Storage.Implementations.File;
public class StoreHandlerFactory
{
private static Dictionary<KeyType, IStoreHandler> _handlers = new();
private static object lockObject = new();
public static IStoreHandler GetInstance(KeyType type)
{
IStoreHandler handler;
lock (lockObject)
{
if (!_handlers.TryGetValue(type, out handler))
{
handler = type switch
{
KeyType.Unique => new FlatStoreHandler(),
KeyType.Subdivisioned => new SubdivisionedStoreHandler(),
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
};
_handlers.Add(type, handler);
}
}
return handler;
}
}