| name | shiny-stores |
| description | Generate and configure Shiny Stores for .NET - cross-platform key/value stores with persistent service binding for mobile, desktop, and Blazor WebAssembly |
| auto_invoke | true |
| triggers | ["IKeyValueStore","IObjectStoreBinder","IKeyValueStoreFactory","AddShinyStores","AddPersistentService","ObjectStoreBinderAttribute","AddShinyWebAssemblyStores","Shiny.Extensions.Stores","Shiny.Extensions.Stores.Web"] |
Shiny Stores Skill
Triggers
- IKeyValueStore
- IObjectStoreBinder
- IKeyValueStoreFactory
- AddShinyStores
- AddPersistentService
- ObjectStoreBinderAttribute
- AddShinyWebAssemblyStores
- Shiny.Extensions.Stores
- Shiny.Extensions.Stores.Web
You are an expert in Shiny Extensions Stores, a .NET library providing cross-platform key/value store abstraction with persistent service binding.
When to Use This Skill
Invoke this skill when the user wants to:
- Use cross-platform key/value stores (settings, secure storage, memory)
- Bind
INotifyPropertyChanged objects to persistent storage
- Use key/value stores in Blazor WebAssembly (localStorage, sessionStorage)
- Create custom key/value store implementations
Library Overview
Documentation: https://shinylib.net/extensions/stores/
Repository: https://github.com/shinyorg/Shiny.Extensions
Packages: Shiny.Extensions.Stores, Shiny.Extensions.Stores.Web
Built-in Store Aliases
| Alias | Platform | Implementation |
|---|
"memory" | All | In-memory dictionary |
"settings" | Android | SharedPreferences |
"settings" | iOS/macOS | NSUserDefaults |
"settings" | Windows | ApplicationData.LocalSettings |
"settings" | Blazor | localStorage |
"secure" | Android | EncryptedSharedPreferences |
"secure" | iOS/macOS | Keychain |
"session" | Blazor | sessionStorage |
Setup
services.AddShinyStores();
services.AddShinyWebAssemblyStores();
Using Stores Directly
public class MyService(IKeyValueStoreFactory storeFactory)
{
public void SaveSetting(string key, string value)
{
var store = storeFactory.GetStore("settings");
store.Set(key, value);
}
public T GetSetting<T>(string key, T defaultValue = default)
{
var store = storeFactory.DefaultStore;
return store.Get<T>(key, defaultValue);
}
}
Persistent Services (Object-Store Binding)
Bind INotifyPropertyChanged objects to a store so property changes are automatically persisted:
services.AddPersistentService<AppSettings>();
services.AddPersistentService<SecureSettings>("secure");
public class AppSettings : INotifyPropertyChanged
{
string theme = "light";
public string Theme
{
get => theme;
set { theme = value; OnPropertyChanged(); }
}
}
You can also target a specific store with the attribute:
[ObjectStoreBinder("secure")]
public class SecureSettings : INotifyPropertyChanged
{
}
Store Extension Methods
store.Get<T>(key, defaultValue);
store.GetRequired<T>(key);
store.SetOrRemove(key, value);
store.SetDefault<T>(key, value);
store.IncrementValue(key);
Code Generation Instructions
- Use
AddShinyStores() for mobile/desktop, AddShinyWebAssemblyStores() for Blazor
- Use
AddPersistentService<T>() for auto-persisting settings classes
- Always implement
INotifyPropertyChanged for persistent services
- Specify the store alias when targeting secure storage
Best Practices
- Use persistent services - For app settings that should survive restarts, use
AddPersistentService<T>()
- Target secure store - Always use the
"secure" store alias for sensitive data (tokens, credentials)
- Use Shiny Reflector - Mark persistent service classes with
[Reflector] and make them partial to bypass reflection for faster binding