hanssens / localstorage

LocalStorage for .NET - A simple and lightweight tool for persisting data in dotnet (core) apps.
MIT License
74 stars 17 forks source link

Add safe helpers for retrieval, preventing KeyNotFoundException #16

Open hanssens opened 7 years ago

hanssens commented 7 years ago

E.g. TryGet() and TryQuery().

n-alex-white commented 7 years ago

I presume this is to resolve the kind of problem which I've just seen, where I received a "Could not find key 'xyz' in the LocalStorage" exception when I attempted a Get for a key which wasn't yet populated.

I was reading your instructions and couldn't spot how I ought to be checking for a key before I attempt to get it. Is there a process which I should be using that I'm missing?

Cheers

hanssens commented 7 years ago

@n-alex-white Indeed. I'll be adding these operations in the upcoming version. I'm also contemplating about an additional Exists() method for the sole purpose of readability (e.g. code eloquence if you will).

ETA for the updated version is this month. Hope you can wait for this.