Shiny.Extensions.DependencyInjection
4.0.0-beta-0002
Prefix Reserved
See the version list below for details.
dotnet add package Shiny.Extensions.DependencyInjection --version 4.0.0-beta-0002
NuGet\Install-Package Shiny.Extensions.DependencyInjection -Version 4.0.0-beta-0002
<PackageReference Include="Shiny.Extensions.DependencyInjection" Version="4.0.0-beta-0002" />
<PackageVersion Include="Shiny.Extensions.DependencyInjection" Version="4.0.0-beta-0002" />
<PackageReference Include="Shiny.Extensions.DependencyInjection" />
paket add Shiny.Extensions.DependencyInjection --version 4.0.0-beta-0002
#r "nuget: Shiny.Extensions.DependencyInjection, 4.0.0-beta-0002"
#:package Shiny.Extensions.DependencyInjection@4.0.0-beta-0002
#addin nuget:?package=Shiny.Extensions.DependencyInjection&version=4.0.0-beta-0002&prerelease
#tool nuget:?package=Shiny.Extensions.DependencyInjection&version=4.0.0-beta-0002&prerelease
Shiny Extensions
Dependency Injection Extensions
- Source generate all attributed classes to a single add file - saves you the boilerplate
- Extension methods for registering a dependency against multiple interfaces
- Supports multiple interfaces
- Supports open generics
- Supports keyed services
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
- Install the NuGet package
Shiny.Extensions.DependencyInjection - Add the following using directive:
// during your app startup - use your service collection builder.Services.AddGeneratedServices(); - Add the
[Service(ServiceLifetime.Singleton, "optional key")]attribute to your classes and specify the lifetime and optional key
Stores
- Key/value store with support for
- Android/iOS/Windows - Preferences & Secure Storage
- Web - Local Storage & Session Storage
- In Memory
- Object binder binds INotifyPropertyChanged against a key/value store to persist object changes across sessions
- Simply implement IKeyValueStore to create your own store
Setup
- Install the NuGet package
Shiny.Extensions.Stores - Add the following using directive:
// during your app startup - use your service collection
builder.Services.AddPersistentService<MyNotifyPropertyChangedObject>("secure"); // optional: default to `settings`
- Inject the MyNotifyPropertyChangedObject into your view model or service. Set properties and they will be persisted automatically.
- To bypass reflection and make binding super fast - use Shiny Reflector to remove the need for reflection. It is already built into the Shiny.Extensions.Stores package, so you can use it directly. Just mark
[Reflector]on your class and make your class partial.
Available Stores Per Platform
| Platform | Store Alias | Description |
|---|---|---|
| Android | settings | Preferences store |
| Android | secure | Secure Storage |
| iOS | settings | Preferences store |
| iOS | secure | Secure Storage |
| WebAssembly | settings | Local Storage |
| WebAssembly | session | Session Storage |
| All | Memory | In Memory store - great for testing |
For WebAssembly, install the Shiny.Extensions.Stores.Web package and add services.AddWebAssemblyStores() to your service collection.
Web Hosting Extensions
- Merges service container build and post build scenarios into a single class using
IWebModule
Setup
- Install the NuGet package
Shiny.Extensions.WebHosting - 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 } } - 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.Servicesfor accessing the service provider anywhere - Platform lifecycle hooks via
ILifecycleExecutor(foreground/background events, activity results, etc.)
Setup
- Install the NuGet package
Shiny.Extensions.MauiHosting - 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) } } - In your
MauiProgram.cs:using Shiny; var builder = MauiApp.CreateBuilder(); builder .UseMauiApp<App>() .AddInfrastructureModules(new MyMauiModule()); return builder.Build(); - Access services anywhere via
Host.Services
Additional Libraries Used
- Shiny Reflector - Reflection without the actual reflection
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
NuGet packages (22)
Showing the top 5 NuGet packages that depend on Shiny.Extensions.DependencyInjection:
| 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 (1)
Showing the top 1 popular GitHub repositories that depend on Shiny.Extensions.DependencyInjection:
| Repository | Stars |
|---|---|
|
shinyorg/templates
dotnet CLI & Visual Studio Templates
|
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.0 | 0 | 5/28/2026 |
| 4.0.0-beta-0063 | 0 | 5/27/2026 |
| 4.0.0-beta-0062 | 0 | 5/27/2026 |
| 4.0.0-beta-0061 | 0 | 5/27/2026 |
| 4.0.0-beta-0060 | 26 | 5/27/2026 |
| 4.0.0-beta-0059 | 38 | 5/27/2026 |
| 4.0.0-beta-0058 | 101 | 5/26/2026 |
| 4.0.0-beta-0057 | 35 | 5/26/2026 |
| 4.0.0-beta-0056 | 108 | 5/22/2026 |
| 4.0.0-beta-0041 | 125 | 5/18/2026 |
| 4.0.0-beta-0005 | 101 | 5/22/2026 |
| 4.0.0-beta-0004 | 116 | 5/20/2026 |
| 4.0.0-beta-0003 | 113 | 5/19/2026 |
| 4.0.0-beta-0002 | 115 | 5/18/2026 |
| 3.0.0 | 224 | 4/30/2026 |
| 2.1.0-beta-0045 | 119 | 4/3/2026 |
| 2.1.0-beta-0044 | 106 | 4/3/2026 |
| 2.1.0-beta-0043 | 117 | 3/18/2026 |
| 2.0.4 | 496 | 4/3/2026 |
| 2.0.3 | 183 | 3/18/2026 |