Prognosis.DependencyInjection
6.0.0
See the version list below for details.
dotnet add package Prognosis.DependencyInjection --version 6.0.0
NuGet\Install-Package Prognosis.DependencyInjection -Version 6.0.0
<PackageReference Include="Prognosis.DependencyInjection" Version="6.0.0" />
<PackageVersion Include="Prognosis.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Prognosis.DependencyInjection" />
paket add Prognosis.DependencyInjection --version 6.0.0
#r "nuget: Prognosis.DependencyInjection, 6.0.0"
#:package Prognosis.DependencyInjection@6.0.0
#addin nuget:?package=Prognosis.DependencyInjection&version=6.0.0
#tool nuget:?package=Prognosis.DependencyInjection&version=6.0.0
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>(Importance.Required);
app.DependsOn("NotificationSystem", Importance.Important);
});
health.MarkAsRoot("Application");
health.UseMonitor(TimeSpan.FromSeconds(30));
});
API
Assembly scanning
ScanForServices discovers all concrete IHealthAware implementations in the given assemblies and registers them as singletons. It also reads [DependsOn<T>] attributes to auto-wire dependency edges:
[DependsOn<DatabaseService>(Importance.Required)]
[DependsOn<CacheService>(Importance.Important)]
class AuthService : IHealthAware
{
public HealthNode HealthNode { get; } = HealthNode.CreateDelegate("AuthService");
}
Composite nodes
Define virtual aggregation points whose health is derived entirely from their dependencies:
health.AddComposite("NotificationSystem", n =>
{
n.DependsOn("MessageQueue", Importance.Required);
n.DependsOn("EmailProvider", Importance.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
: HealthEvaluation.Unhealthy("SMTP refused"));
Roots
Designate the root of the health graph with MarkAsRoot. When only one root is declared (or auto-detected), a plain HealthGraph singleton is registered:
health.MarkAsRoot("Application"); // by name
health.MarkAsRoot<ApplicationRoot>(); // by type — also registers HealthGraph<ApplicationRoot>
If MarkAsRoot is not called and exactly one node has no parent, it is chosen automatically. If there are zero or more than one candidate, an exception is thrown at graph materialization with guidance to call MarkAsRoot.
Multiple roots (shared nodes, separate graphs)
Call MarkAsRoot more than once to materialize several HealthGraph instances from a single shared node pool. Each graph walks a different root but the underlying HealthNode instances (and their health state) are shared:
builder.Services.AddPrognosis(health =>
{
health.ScanForServices(typeof(Program).Assembly);
health.AddComposite("Ops", ops =>
{
ops.DependsOn<DatabaseService>(Importance.Required);
ops.DependsOn<CacheService>(Importance.Required);
});
health.AddComposite("Customer", cust =>
{
cust.DependsOn<AuthService>(Importance.Required);
});
health.MarkAsRoot("Ops");
health.MarkAsRoot("Customer");
});
With multiple roots:
- Each graph is registered as a keyed
HealthGraph(keyed by the root name). - Use
MarkAsRoot<T>()to also register aHealthGraph<T>for consumers without keyed service support.
// Keyed resolution (Microsoft.Extensions.DependencyInjection 8+):
var opsGraph = sp.GetRequiredKeyedService<HealthGraph>("Ops");
var custGraph = sp.GetRequiredKeyedService<HealthGraph>("Customer");
// Generic resolution (any DI container):
var opsGraph = sp.GetRequiredService<HealthGraph<OpsRoot>>().Graph;
HealthGraph
The materialized graph is registered as a singleton (single root) or as keyed singletons (multiple roots). Inject it to access the root, 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.
HealthNode db = graph["Database"];
// Enumerate all nodes reachable from the root.
foreach (var node in graph.Nodes)
{
Console.WriteLine($"{node.Name}: {node}");
}
The Rx extensions in Prognosis.Reactive operate directly on HealthGraph:
graph.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.
Dependencies
- Prognosis (core library)
- Microsoft.Extensions.DependencyInjection.Abstractions >= 9.0.0
- Microsoft.Extensions.Hosting.Abstractions >= 9.0.0
Requirements
- .NET Standard 2.0+ (.NET Framework 4.6.1+, .NET Core 2.0+, .NET 5+)
| Product | Versions 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. |
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.5)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.5)
- Prognosis (>= 6.0.0)
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.5)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.5)
- Prognosis (>= 6.0.0)
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 |
|---|---|---|
| 7.0.0-beta.3 | 37 | 3/9/2026 |
| 7.0.0-beta.2 | 34 | 3/8/2026 |
| 7.0.0-beta.1 | 38 | 3/3/2026 |
| 7.0.0-alpha | 79 | 3/2/2026 |
| 6.1.0 | 85 | 3/2/2026 |
| 6.0.0 | 84 | 3/1/2026 |
| 5.0.0 | 86 | 2/28/2026 |
| 4.1.0 | 85 | 2/27/2026 |
| 4.0.0 | 85 | 2/26/2026 |
| 4.0.0-alpha | 85 | 2/26/2026 |
| 3.0.1 | 95 | 2/19/2026 |
| 3.0.0 | 93 | 2/19/2026 |
| 3.0.0-beta | 91 | 2/18/2026 |
| 3.0.0-alpha | 95 | 2/18/2026 |
| 2.1.0 | 89 | 2/16/2026 |
| 2.0.0 | 95 | 2/15/2026 |
| 1.0.0 | 103 | 2/14/2026 |