Prognosis.DependencyInjection 2.1.0

dotnet add package Prognosis.DependencyInjection --version 2.1.0
                    
NuGet\Install-Package Prognosis.DependencyInjection -Version 2.1.0
                    
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="Prognosis.DependencyInjection" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Prognosis.DependencyInjection" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Prognosis.DependencyInjection" />
                    
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 Prognosis.DependencyInjection --version 2.1.0
                    
#r "nuget: Prognosis.DependencyInjection, 2.1.0"
                    
#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 Prognosis.DependencyInjection@2.1.0
                    
#: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=Prognosis.DependencyInjection&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Prognosis.DependencyInjection&version=2.1.0
                    
Install as a Cake Tool

Prognosis.DependencyInjection

Microsoft.Extensions.DependencyInjection integration for the Prognosis service health graph. Provides assembly scanning, a fluent graph builder, and hosted service monitoring.

Installation

dotnet add package Prognosis.DependencyInjection

Quick start

using Prognosis.DependencyInjection;

builder.Services.AddPrognosis(health =>
{
    health.ScanForServices(typeof(Program).Assembly);

    health.AddComposite("Application", app =>
    {
        app.DependsOn<AuthService>(ServiceImportance.Required);
        app.DependsOn("NotificationSystem", ServiceImportance.Important);
    });

    health.AddRoots("Application");
    health.UseMonitor(TimeSpan.FromSeconds(30));
});

API

Assembly scanning

ScanForServices discovers all concrete IServiceHealth implementations in the given assemblies and registers them as singletons. It also reads [DependsOn<T>] attributes to auto-wire dependency edges:

[DependsOn<DatabaseService>(ServiceImportance.Required)]
[DependsOn<CacheService>(ServiceImportance.Important)]
class AuthService : IObservableServiceHealth
{
    private readonly ServiceHealthTracker _health = new();

    public string Name => "AuthService";
    public IReadOnlyList<ServiceDependency> Dependencies => _health.Dependencies;
    public IObservable<HealthStatus> StatusChanged => _health.StatusChanged;
    public void NotifyChanged() => _health.NotifyChanged();
    public HealthEvaluation Evaluate() => _health.Evaluate();
}

Composite nodes

Define virtual aggregation points whose health is derived entirely from their dependencies:

health.AddComposite("NotificationSystem", n =>
{
    n.DependsOn("MessageQueue", ServiceImportance.Required);
    n.DependsOn("EmailProvider", ServiceImportance.Optional);
});

Dependencies can reference services by type (DependsOn<T>) or by name (DependsOn("name")).

Delegate wrappers

Wrap a DI-registered service you don't own with a health-check delegate:

health.AddDelegate<ThirdPartyEmailClient>("EmailProvider",
    client => client.IsConnected
        ? HealthStatus.Healthy
        : new HealthEvaluation(HealthStatus.Unhealthy, "SMTP refused"));

Roots

Mark named services as top-level graph entry points for monitoring and report generation:

health.AddRoots("Application");

HealthGraph

The materialized graph is registered as a singleton. Inject it to access the roots, look up services by name, or create reports:

var graph = serviceProvider.GetRequiredService<HealthGraph>();

// Create a point-in-time report.
HealthReport report = graph.CreateReport();

// Look up a service by name.
IServiceHealth db = graph["Database"];

// Enumerate all services.
foreach (var svc in graph.Services)
{
    Console.WriteLine($"{svc.Name}: {svc.Evaluate()}");
}

The Roots property is IServiceHealth[], directly compatible with the Rx extensions in Prognosis.Reactive:

graph.Roots.PollHealthReport(TimeSpan.FromSeconds(30)).Subscribe(...);

Hosted monitoring

UseMonitor registers HealthMonitor as an IHostedService that polls on the given interval and stops with the host:

health.UseMonitor(TimeSpan.FromSeconds(30));

This is optional — Rx users can skip it and build their own pipeline from HealthGraph.Roots.

Dependencies

Requirements

  • .NET Standard 2.0+ (.NET Framework 4.6.1+, .NET Core 2.0+, .NET 5+)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 28 2/16/2026
2.0.0 35 2/15/2026
1.0.0 40 2/14/2026