using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; using System.Security.Cryptography; namespace ColorControl.UI.Generics; public static class GeneralExtensions { public static async ValueTask TryGet(this ProtectedBrowserStorage storage, string key, TValue? def = default) { try { var result = await storage.GetAsync(key); var value = result.Success ? result.Value : def; return value; } catch (CryptographicException) { await storage.DeleteAsync(key); return def; } } }