TransientAttribute
NexusLabs.Needlr¶
NexusLabs.Needlr¶
TransientAttribute Class¶
Specifies that the decorated class should be registered with \<b>Transient\</b> lifetime. Transient services are created fresh every time they are resolved from the container.
Inheritance System.Object 🡒 System.Attribute 🡒 TransientAttribute
Example¶
[Transient]
public class EmailMessageBuilder : IEmailMessageBuilder
{
// New instance every time IEmailMessageBuilder is resolved
}
Remarks¶
Use [Transient] for lightweight, stateless services that are cheap to construct
and must not accumulate state across calls.
Without this attribute, Needlr registers classes as Singleton by default.
Apply [Transient] to override that default.