ConfiguredSyringe
NexusLabs.Needlr.Injection¶
NexusLabs.Needlr.Injection¶
ConfiguredSyringe Class¶
Represents a Syringe that has been configured with a strategy (UsingReflection, UsingSourceGen, or UsingAutoConfiguration). This type has access to all configuration extension methods and can build a service provider.
public sealed record ConfiguredSyringe : System.IEquatable<NexusLabs.Needlr.Injection.ConfiguredSyringe>
Inheritance System.Object 🡒 ConfiguredSyringe
Implements System.IEquatable<ConfiguredSyringe>
Remarks¶
ConfiguredSyringe is created by calling one of the strategy methods on Syringe:
- new Syringe().UsingReflection() - uses reflection-based type discovery
- new Syringe().UsingSourceGen() - uses source-generated type discovery
- new Syringe().UsingAutoConfiguration() - automatically selects best available strategy
Once configured, use extension methods to further customize the container, then call BuildServiceProvider(IConfiguration) to create the service provider.
Methods¶
ConfiguredSyringe.BuildServiceProvider(IConfiguration) Method¶
Builds a service provider with the configured settings. Automatically runs container verification based on NexusLabs.Needlr.Injection.ConfiguredSyringe.VerificationOptions.
public System.IServiceProvider BuildServiceProvider(Microsoft.Extensions.Configuration.IConfiguration config);
Parameters¶
config Microsoft.Extensions.Configuration.IConfiguration
The configuration to use for building the service provider.
Returns¶
System.IServiceProvider
The configured System.IServiceProvider.
Exceptions¶
System.InvalidOperationException
Thrown if required components (TypeRegistrar, TypeFilterer, PluginFactory, AssemblyProvider) are not configured.
NexusLabs.Needlr.ContainerVerificationException
Thrown if verification issues are detected and the configured behavior is NexusLabs.Needlr.VerificationBehavior.Throw.
ConfiguredSyringe.GetAdditionalAssemblies() Method¶
Gets the configured additional assemblies.
public System.Collections.Generic.IReadOnlyList<System.Reflection.Assembly> GetAdditionalAssemblies();
Returns¶
System.Collections.Generic.IReadOnlyList<System.Reflection.Assembly>
ConfiguredSyringe.GetOrCreateAssemblyProvider() Method¶
Gets the configured assembly provider, with ordering applied if configured.
Returns¶
Exceptions¶
System.InvalidOperationException
Thrown if no assembly provider is configured. This should not happen if the syringe was created
via UsingReflection(), UsingSourceGen(), or UsingAutoConfiguration().
ConfiguredSyringe.GetOrCreatePluginFactory() Method¶
Gets the configured plugin factory.
Returns¶
NexusLabs.Needlr.IPluginFactory
Exceptions¶
System.InvalidOperationException
Thrown if no plugin factory is configured. This should not happen if the syringe was created
via UsingReflection(), UsingSourceGen(), or UsingAutoConfiguration().
ConfiguredSyringe.GetOrCreateServiceCollectionPopulator(ITypeRegistrar, ITypeFilterer, IPluginFactory) Method¶
Gets the configured service collection populator or creates a default one.
public NexusLabs.Needlr.Injection.IServiceCollectionPopulator GetOrCreateServiceCollectionPopulator(NexusLabs.Needlr.Injection.ITypeRegistrar typeRegistrar, NexusLabs.Needlr.Injection.ITypeFilterer typeFilterer, NexusLabs.Needlr.IPluginFactory pluginFactory);
Parameters¶
typeRegistrar ITypeRegistrar
typeFilterer ITypeFilterer
pluginFactory NexusLabs.Needlr.IPluginFactory
Returns¶
ConfiguredSyringe.GetOrCreateServiceProviderBuilder(IServiceCollectionPopulator, IAssemblyProvider, IReadOnlyList<Assembly>) Method¶
Gets the configured service provider builder or throws if not configured.
public NexusLabs.Needlr.Injection.IServiceProviderBuilder GetOrCreateServiceProviderBuilder(NexusLabs.Needlr.Injection.IServiceCollectionPopulator serviceCollectionPopulator, NexusLabs.Needlr.Injection.IAssemblyProvider assemblyProvider, System.Collections.Generic.IReadOnlyList<System.Reflection.Assembly> additionalAssemblies);
Parameters¶
serviceCollectionPopulator IServiceCollectionPopulator
assemblyProvider IAssemblyProvider
additionalAssemblies System.Collections.Generic.IReadOnlyList<System.Reflection.Assembly>
Returns¶
Exceptions¶
System.InvalidOperationException
Thrown if no service provider builder factory is configured. This should not happen if the syringe was created
via UsingReflection(), UsingSourceGen(), or UsingAutoConfiguration().
ConfiguredSyringe.GetOrCreateTypeFilterer() Method¶
Gets the configured type filterer or creates an empty one.
Returns¶
ConfiguredSyringe.GetOrCreateTypeRegistrar() Method¶
Gets the configured type registrar.
Returns¶
Exceptions¶
System.InvalidOperationException
Thrown if no type registrar is configured. This should not happen if the syringe was created
via UsingReflection(), UsingSourceGen(), or UsingAutoConfiguration().
ConfiguredSyringe.GetPostPluginRegistrationCallbacks() Method¶
Gets the configured post-plugin registration callbacks.
public System.Collections.Generic.IReadOnlyList<System.Action<Microsoft.Extensions.DependencyInjection.IServiceCollection>> GetPostPluginRegistrationCallbacks();
Returns¶
System.Collections.Generic.IReadOnlyList<System.Action<Microsoft.Extensions.DependencyInjection.IServiceCollection>>