Skip to content

Syringe

NexusLabs.Needlr.Injection

NexusLabs.Needlr.Injection

Syringe Class

The base container for configuring Needlr service discovery.

public sealed record Syringe : System.IEquatable<NexusLabs.Needlr.Injection.Syringe>

Inheritance System.Object 🡒 Syringe

Implements System.IEquatable<Syringe>

Example

// Using reflection
var provider = new Syringe()
    .UsingReflection()
    .BuildServiceProvider();

// Using source generation (AOT-compatible)
var provider = new Syringe()
    .UsingSourceGen()
    .BuildServiceProvider();

Remarks

Syringe is a starting point that must be configured with a strategy before building. Use one of these approaches to get a ConfiguredSyringe that can build a service provider: - Reference NexusLabs.Needlr.Injection.SourceGen and call .UsingSourceGen() - Reference NexusLabs.Needlr.Injection.Reflection and call .UsingReflection() - Reference NexusLabs.Needlr.Injection.Bundle and call .UsingAutoConfiguration()

The strategy methods return a ConfiguredSyringe which has the BuildServiceProvider() method.