Immediate.Injections
Attributes
Immediate.Injections provides attributes to mark classes for registration and options to control how they are registered.
Registration Attributes
RegisterSingleton: registers the type as a singleton.RegisterScoped: registers the type as scoped.RegisterTransient: registers the type as transient.
ServiceType
Registers the class as the specified service type. The class must be assignable to it.
Alternatively, a concrete registration may be declared using generic attributes.
RegistrationStrategy
Controls which service types are generated. Mutually exclusive with ServiceType.
DuplicateStrategy
Controls what happens when a registration for the same service type already exists.
ServiceKey
Registers the service as a keyed service.
Factory
Name of a static factory method on the class to use as ImplementationFactory. The method must be static, return the
class type, and accept (IServiceProvider) for non-keyed or (IServiceProvider, object) for keyed registrations.
Cannot be combined with UseProxyFactory or used on open generic types. Factories cannot be used with generic target
classes.
UseProxyFactory
When true, the registration uses ServiceProviderServiceExtensions.GetRequiredService<T> (or the keyed equivalent) as
the factory. This produces a proxy registration — it does not register the implementation itself, but resolves it from
the container.
UseProxyFactory = true be combined with the following:
- A provided
Factory, RegistrationStrategy = Self, or- Generic target classes
Tags
Assigns string tags to the registration. When AddXxxServices is called with tag arguments, only registrations that share at least one tag (or registrations with no tags) are included.