using Services;

namespace IGP.Calculator.Cli.Services;

public class NullStorageService : IStorageService
{
    private readonly Dictionary<string, object?> _store = new();

    public void Subscribe(Action action)
    {
    }

    public void Unsubscribe(Action action)
    {
    }

    public T GetValue<T>(string forKey)
    {
        if (_store.TryGetValue(forKey, out var value) && value is T typed)
            return typed;
        return default!;
    }

    public void SetValue<T>(string key, T value)
    {
        _store[key] = value;
    }

    public Task Load()
    {
        return Task.CompletedTask;
    }
}