2024-01-30 14:54:01 +00:00
|
|
|
|
using LootDumpProcessor.Storage.Implementations.File.Handlers;
|
2023-08-12 19:08:38 +01:00
|
|
|
|
|
2024-01-30 14:54:01 +00:00
|
|
|
|
namespace LootDumpProcessor.Storage.Implementations.File;
|
2023-08-12 19:08:38 +01:00
|
|
|
|
|
|
|
|
|
public class StoreHandlerFactory
|
|
|
|
|
{
|
2024-01-30 14:54:01 +00:00
|
|
|
|
private static Dictionary<KeyType, IStoreHandler> _handlers = new();
|
|
|
|
|
private static object lockObject = new();
|
2023-08-12 19:08:38 +01:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|