using Blazored.LocalStorage;
using System.Runtime.CompilerServices;

namespace FNZCM.BlazorWasm.Helpers
{
    public class LocalStorageHelper
    {
        private readonly ISyncLocalStorageService localStorage;

        public LocalStorageHelper(ISyncLocalStorageService localStorage) => this.localStorage = localStorage;

        public void Set<T>(T value, [CallerMemberName] string key = null) => localStorage.SetItem(key, value);
        public T Get<T>([CallerMemberName] string key = null) => localStorage.GetItem<T>(key);
        public void Remove([CallerMemberName] string key = null) => localStorage.RemoveItem(key);
        public void Clear() => localStorage.Clear();
    }
}
