ContainerRegisterSingleton Method

Simple Injector
Overload List

  NameDescription
Public methodRegisterSingletonTConcrete
Registers a single concrete instance that will be constructed using constructor injection and will be returned when this instance is requested by type TConcrete. This TConcrete must be thread-safe when working in a multi-threaded environment. If TConcrete implements IDisposable, a created instance will get disposed when Container.Dispose gets called.
Public methodRegisterSingletonTService, TImplementation
Registers that the same a single instance of type TImplementation will be returned every time an TService type is requested. If TService and TImplementation represent the same type, the type is registered by itself. TImplementation must be thread-safe when working in a multi-threaded environment. If TImplementation implements IDisposable, a created instance will get disposed when Container.Dispose gets called.
Public methodRegisterSingletonTService(FuncTService)
Registers the specified delegate that allows constructing a single instance of TService. This delegate will be called at most once during the lifetime of the application. The returned instance must be thread-safe when working in a multi-threaded environment. If the instance returned from instanceCreator implements IDisposable, the created instance will get disposed when Container.Dispose gets called.
Public methodRegisterSingletonTService(TService) Obsolete.
Registers a single instance that will be returned when an instance of type TService is requested. 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, since the instance is assumed to outlive this container instance. If disposing is required, use the overload that accepts a FuncTResult delegate.
Public methodRegisterSingleton(Type, IEnumerableAssembly)
Registers all concrete, non-generic, public and internal types in the given set of assemblies that implement the given openGenericServiceType with Singleton lifestyle. Decorators and generic type definitions will be excluded from registration, while composites are included.
Public methodRegisterSingleton(Type, FuncObject)
Registers the specified delegate that allows constructing a single serviceType instance. The container will call this delegate at most once during the lifetime of the application.
Public methodRegisterSingleton(Type, Object) Obsolete.
Registers a single instance that will be returned when an instance of type serviceType is requested. This instance must be thread-safe when working in a multi-threaded environment.
Public methodRegisterSingleton(Type, Assembly)
Registers all concrete, non-generic, public and internal types in the given set of assemblies that implement the given openGenericServiceType with Singleton lifestyle. Decorators and generic type definitions will be excluded from registration, while composites are included.
Public methodRegisterSingleton(Type, Type)
Registers that the same instance of type implementationType will be returned every time an instance of type serviceType type is requested. If serviceType and implementationType represent the same type, the type is registered by itself. implementationType must be thread-safe when working in a multi-threaded environment. Open and closed generic types are supported.
Top
See Also

Reference