Shiny.Extensions.Stores 4.0.0-beta-0003

Prefix Reserved
This is a prerelease version of Shiny.Extensions.Stores.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Shiny.Extensions.Stores --version 4.0.0-beta-0003
                    
NuGet\Install-Package Shiny.Extensions.Stores -Version 4.0.0-beta-0003
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shiny.Extensions.Stores" Version="4.0.0-beta-0003" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shiny.Extensions.Stores" Version="4.0.0-beta-0003" />
                    
Directory.Packages.props
<PackageReference Include="Shiny.Extensions.Stores" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Shiny.Extensions.Stores --version 4.0.0-beta-0003
                    
#r "nuget: Shiny.Extensions.Stores, 4.0.0-beta-0003"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Shiny.Extensions.Stores@4.0.0-beta-0003
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Shiny.Extensions.Stores&version=4.0.0-beta-0003&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Shiny.Extensions.Stores&version=4.0.0-beta-0003&prerelease
                    
Install as a Cake Tool

Shiny Extensions

Dependency Injection Extensions

  • Source generate all attributed classes to a single add file - saves you the boilerplate
  • Factory-form emission - generated registrations expand the constructor at compile time (no reflection, AOT-clean) so resolve chains like OnResolved compose naturally
  • ActivatorUtilities-style constructor selection ([ActivatorUtilitiesConstructor] and [FromKeyedServices] honored)
  • Multiple interfaces via explicit forwarders (no reflection)
  • Supports open generics and keyed services
  • OnResolved<T>(hook) chain extension for one-shot post-construction hooks

The Results

THIS:

using Microsoft.Extensions.DependencyInjection;
using Shiny;

// given the following code from a user
namespace Sample
{
    public interface IStandardInterface;

    public interface IStandardInterface2;

    [Service(ServiceLifetime.Singleton)]
    public class ImplementationOnly;

    [Service(ServiceLifetime.Transient, "ImplOnly")]
    public class KeyedImplementationOnly;


    [Service(ServiceLifetime.Singleton)]
    public class StandardImplementation : IStandardInterface;

    [Service(ServiceLifetime.Scoped, "Standard")]
    public class KeyedStandardImplementation : IStandardInterface;

    [Service(ServiceLifetime.Singleton)]
    public class MultipleImplementation : IStandardInterface, IStandardInterface2;

    [Service(ServiceLifetime.Scoped)]
    public class ScopedMultipleImplementation : IStandardInterface, IStandardInterface2;


    [Service(ServiceLifetime.Scoped, "KeyedGeneric")]
    public class TestGeneric<T1, T2>
    {
        public T1 Value1 { get; set; }
        public T2 Value2 { get; set; }
    }
}

GENERATES THIS:

// <auto-generated />
using global::Microsoft.Extensions.DependencyInjection;
using global::Shiny;

namespace Sample
{
    public static class __GeneratedRegistrations
    {
        public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddGeneratedServices(
            this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services
        )
        {
            services.AddSingleton<global::Sample.ImplementationOnly>();
            services.AddKeyedTransient<global::Sample.KeyedImplementationOnly>("ImplOnly");
            services.AddSingleton<global::Sample.IStandardInterface, global::Sample.StandardImplementation>();
            services.AddKeyedScoped<global::Sample.IStandardInterface, global::Sample.KeyedStandardImplementation>("Standard");
            services.AddSingletonAsImplementedInterfaces<global::Sample.MultipleImplementation>();
            services.AddScopedAsImplementedInterfaces<global::Sample.ScopedMultipleImplementation>();
            services.AddKeyedScoped(typeof(global::Sample.TestGeneric<,>), "KeyedGeneric");

            return services;
        }
    }
}

Setup

  1. Install the NuGet package Shiny.Extensions.DependencyInjection
  2. Add the following using directive:
    // during your app startup - use your service collection 
    builder.Services.AddGeneratedServices();
    
  3. Add the [Service(ServiceLifetime.Singleton, "optional key")] attribute to your classes and specify the lifetime and optional key

Stores

  • Cross-platform key/value store with support for
    • Android/iOS/Windows - Preferences & Secure Storage
    • Web - Local Storage
    • In Memory
  • Source-generated [Bind] attribute on partial properties - emits getter/setter bodies that round-trip through the store (no INPC required, no runtime reflection, fully AOT)
  • Static Shiny.Stores.Default/Secure/Keyed(...) accessor for direct ad-hoc reads/writes
  • Implement IKeyValueStore to plug in your own store

Setup

  1. Install the NuGet package Shiny.Extensions.Stores
  2. Register at startup:
    builder.Services.AddShinyStores();
    
  3. Define your settings as a partial class with [Bind] partial properties:
    using Shiny;
    
    [Singleton]
    public partial class AppSettings
    {
        [Bind]                       // default store
        public partial string Theme { get; set; }
    
        [Bind("secure")]             // secure store
        public partial string Token { get; set; }
    }
    
  4. Inject AppSettings anywhere. Set properties — they persist. Read properties — they come from the store.

Or skip the class and use the static accessor:

Shiny.Stores.Default.Set("theme", "dark");
var theme = Shiny.Stores.Default.Get<string>("theme");

Available Stores Per Platform

Platform Key Description
Android StoreKeys.Default Preferences
Android StoreKeys.Secure Secure Storage
iOS StoreKeys.Default NSUserDefaults
iOS StoreKeys.Secure Keychain
Windows StoreKeys.Default ApplicationData.LocalSettings
Windows StoreKeys.Secure Secure Storage
WebAssembly StoreKeys.Default localStorage
WebAssembly "session" sessionStorage
All any In-memory dictionary (great for testing)

For WebAssembly, install the Shiny.Extensions.Stores.Web package and add services.AddShinyWebAssemblyStores() to your service collection.

Web Hosting Extensions

  • Merges service container build and post build scenarios into a single class using IWebModule

Setup

  1. Install the NuGet package Shiny.Extensions.WebHosting
  2. Add a web module by implementing IWebModule:
    using Shiny;
    
    public class MyWebModule : IWebModule
    {
        public void Add(WebApplicationBuilder builder)
        {
            // Register your services here
        }
    
        public void Use(WebApplication app)
        {
            // Configure your middleware/endpoints here
        }
    }
    
  3. In your application hosting startup, add the following:
    using Shiny;
    
    var builder = WebApplication.CreateBuilder(args);
    builder.AddInfrastructureModules(new MyWebModule());
    
    var app = builder.Build();
    app.UseInfrastructureModules();
    

MAUI Hosting Extensions

  • Module-based MAUI app configuration with IMauiModule
  • Static Host.Services for accessing the service provider anywhere
  • Platform lifecycle hooks via ILifecycleExecutor (foreground/background events, activity results, etc.)

Setup

  1. Install the NuGet package Shiny.Extensions.MauiHosting
  2. Create a MAUI module by implementing IMauiModule:
    using Shiny;
    
    public class MyMauiModule : IMauiModule
    {
        public void Add(MauiAppBuilder builder)
        {
            // Register your services here
        }
    
        public void Use(IPlatformApplication app)
        {
            // Post-build initialization here (do NOT block)
        }
    }
    
  3. In your MauiProgram.cs:
    using Shiny;
    
    var builder = MauiApp.CreateBuilder();
    builder
        .UseMauiApp<App>()
        .AddInfrastructureModules(new MyMauiModule());
    
    return builder.Build();
    
  4. Access services anywhere via Host.Services

Additional Libraries Used

NuGet Packages

Package Description
Shiny.Extensions.DependencyInjection Attribute-driven DI registration with source generators
Shiny.Extensions.Stores Cross-platform key/value store abstraction
Shiny.Extensions.Stores.Web Blazor WebAssembly localStorage/sessionStorage
Shiny.Extensions.WebHosting ASP.NET modular web hosting with IWebModule
Shiny.Extensions.MauiHosting MAUI modular hosting with IMauiModule and platform lifecycle hooks
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-maccatalyst26.0 is compatible.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (23)

Showing the top 5 NuGet packages that depend on Shiny.Extensions.Stores:

Package Downloads
Shiny.Core

The Shiny Core Foundation where all Shiny modules are built on

Shiny.Notifications

Shiny addon for all your notification needs

Shiny.Push

Shiny addon for all your push notification needs

Shiny.BluetoothLE.Common

Shiny BluetoothLE - Common components for Hosting and Client

Shiny.BluetoothLE

Shiny Reactive BluetoothLE Plugin for client/central operations

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.1.0 220 5/29/2026
4.0.0 163 5/28/2026
4.0.0-beta-0063 112 5/27/2026
4.0.0-beta-0062 110 5/27/2026
4.0.0-beta-0061 113 5/27/2026
4.0.0-beta-0060 111 5/27/2026
4.0.0-beta-0059 127 5/27/2026
4.0.0-beta-0058 648 5/26/2026
4.0.0-beta-0057 105 5/26/2026
4.0.0-beta-0056 148 5/22/2026
4.0.0-beta-0041 101 5/18/2026
4.0.0-beta-0005 107 5/22/2026
4.0.0-beta-0004 94 5/20/2026
4.0.0-beta-0003 100 5/19/2026
4.0.0-beta-0002 94 5/18/2026
3.0.0 536 4/30/2026
2.1.0-beta-0045 114 4/3/2026
2.1.0-beta-0044 114 4/3/2026
2.0.4 121 4/3/2026
2.0.3 132 3/18/2026
Loading failed