Appends a single instance to a collection of registrations for the given
TService . Calls to AppendInstance can both preceed and follow a
call to one of the
Container.Collections.Register overloads.
This instance must be thread-safe when working in a multi-threaded environment.
NOTE: Do note that instances supplied by this method NEVER get disposed by the
container; the instance is assumed to outlive this container instance. If disposing is
required, use
RegisterSingleton<TService>(Func<TService>).
Namespace: SimpleInjector
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
Syntax
Parameters
- instance
- Type: TService
The instance to register.
Type Parameters
- TService
- The element type of the collections to register.
Exceptions
Exception | Condition |
---|---|
ArgumentException | Thrown when the TService is ambiguous. |
ArgumentNullException | Thrown when instance is a null reference. |
See Also