The Container type exposes the following members.
Methods
Name | Description | |
---|---|---|
AddRegistration(Type, Registration) |
Adds the registration for the supplied serviceType. This
method can be used to apply the same Registration to multiple different service
types.
| |
AddRegistrationTService(Registration) |
Adds the registration for the supplied . This
method can be used to apply the same Registration to multiple different service
types.
| |
Dispose | Releases all instances that are cached by the Container object. | |
Dispose(Boolean) | Releases all instances that are cached by the Container object. | |
DisposeContainerAsync |
Releases all instances that are cached by the Container object asynchronously.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from ApiObject.) | |
GetAllInstances(Type) |
Gets all instances of the given serviceType currently registered in the container.
| |
GetAllInstancesTService |
Gets all instances of the given TService currently registered in the container.
| |
GetCurrentRegistrations |
Returns an array with the current registrations. This list contains all explicitly registered
types, and all implicitly registered instances. Implicit registrations are all concrete
unregistered types that have been requested, all types that have been resolved using
unregistered type resolution (using the ResolveUnregisteredType event), and
requested unregistered collections. Note that the result of this method may change over time,
because of these implicit registrations.
| |
GetHashCode | Serves as the default hash function. (Inherited from ApiObject.) | |
GetInstance(Type) | Gets an instance of the given serviceType. | |
GetInstanceTService | Gets an instance of the given TService. | |
GetRegistration(Type) |
Gets the InstanceProducer for the given serviceType. When no
registration exists, the container will try creating a new producer. A producer can be created
when the type is a concrete reference type, there is an ResolveUnregisteredType
event registered that acts on that type, or when the service type is an IEnumerableT.
Otherwise null is returned.
| |
GetRegistration(Type, Boolean) |
Gets the InstanceProducer for the given serviceType. When no
registration exists, the container will try creating a new producer. A producer can be created
when the type is a concrete reference type, there is an ResolveUnregisteredType
event registered that acts on that type, or when the service type is an IEnumerableT.
Otherwise null is returned, or an exception is throw when
throwOnFailure is set to true.
| |
GetRegistrationTService |
Gets the InstanceProducer for the given TService. When no
registration exists, the container will try creating a new producer. A producer can be created
when the type is a concrete reference type, there is an ResolveUnregisteredType
event registered that acts on that type, or when the service type is an IEnumerableT.
Otherwise null is returned.
| |
GetRegistrationTService(Boolean) |
Gets the InstanceProducerTService for the given TService.When no
registration exists, the container will try creating a new producer. A producer can be created
when the type is a concrete reference type, there is an ResolveUnregisteredType
event registered that acts on that type, or when the service type is an IEnumerableT.
Otherwise null is returned, or an exception is throw when
throwOnFailure is set to true.
| |
GetRootRegistrations |
Returns an array with the current registrations for root objects. Root objects are registrations
that are in the root of the object graph, meaning that no other registration is depending on it.
| |
GetType | Gets the Type of the current instance. (Inherited from ApiObject.) | |
GetTypesToRegister(Type, IEnumerableAssembly) |
Returns all concrete non-generic types that are located in the supplied assemblies
and implement or inherit from the supplied serviceType.
serviceType can be an open-generic type.
| |
GetTypesToRegister(Type, Assembly) |
Returns all concrete non-generic types that are located in the supplied assemblies
and implement or inherit from the supplied serviceType.
serviceType can be an open-generic type.
| |
GetTypesToRegister(Type, IEnumerableAssembly, TypesToRegisterOptions) |
Returns all concrete types that are located in the supplied assemblies
and implement or inherit from the supplied serviceType and match the specified
options... serviceType can be an open-generic type.
| |
GetTypesToRegisterTService(IEnumerableAssembly) |
Returns all concrete non-generic types that are located in the supplied assemblies
and implement or inherit from the supplied TService.
| |
GetTypesToRegisterTService(Assembly) |
Returns all concrete non-generic types that are located in the supplied assemblies
and implement or inherit from the supplied TService.
| |
GetTypesToRegisterTService(IEnumerableAssembly, TypesToRegisterOptions) |
Returns all concrete types that are located in the supplied assemblies
and implement or inherit from the supplied TService and match the specified
options...
| |
Register(Type) |
Registers that a new instance of concreteType will be returned every time it
is requested (transient).
| |
Register(Type, IEnumerableAssembly) |
Registers all concrete, non-generic, public and internal types in the given set of
assemblies that implement the given openGenericServiceType
with container's default lifestyle (which is transient by default).
Decorators and
generic type definitions
will be excluded from registration, while
composites are included.
| |
Register(Type, IEnumerableType) |
Registers all supplied implementationTypes based on the closed-generic version
of the given openGenericServiceType with the transient lifestyle.
| |
Register(Type, FuncObject) |
Registers the specified delegate that allows returning instances of serviceType.
| |
Register(Type, Assembly) |
Registers all concrete, non-generic, public and internal types in the given set of
assemblies that implement the given openGenericServiceType
with container's default lifestyle (which is transient by default).
Decorators and
generic type definitions
will be excluded from registration, while
composites are included.
| |
Register(Type, Type) |
Registers that a new instance of implementationType will be returned every time a
serviceType is requested. If serviceType and
implementationType represent the same type, the type is registered by itself.
Open and closed generic types are supported.
| |
Register(Type, IEnumerableAssembly, Lifestyle) |
Registers all concrete, non-generic, public and internal types in the given set of
assemblies that implement the given openGenericServiceType
with the supplied lifestyle.
Decorators and
generic type definitions
will be excluded from registration, while
composites are included.
| |
Register(Type, IEnumerableType, Lifestyle) |
Registers all supplied implementationTypes based on the closed-generic version
of the given openGenericServiceType with the given lifestyle.
| |
Register(Type, FuncObject, Lifestyle) |
Registers the specified delegate instanceCreator that will produce instances of
type serviceType and will be returned when an instance of type
serviceType is requested. The delegate is expected to produce new instances on
each call. The instances are cached according to the supplied lifestyle.
| |
Register(Type, Assembly, Lifestyle) |
Registers all concrete, non-generic, public and internal types in the given
assembly that implement the given openGenericServiceType
with the supplied lifestyle.
Decorators and
generic type definitions
will be excluded from registration, while
composites are included.
| |
Register(Type, Type, Lifestyle) |
Registers that an instance of type implementationType will be returned when an
instance of type serviceType is requested. The instance is cached according to
the supplied lifestyle. Open and closed generic types are supported.
| |
RegisterTConcrete |
Registers that a new instance of TConcrete will be returned every time it
is requested (transient).
| |
RegisterTService(FuncTService) |
Registers the specified delegate that allows returning transient instances of
TService. The delegate is expected to always return a new instance on
each call.
| |
RegisterTConcrete(Lifestyle) |
Registers that an instance of TConcrete will be returned when it
is requested. The instance is cached according to the supplied lifestyle.
| |
RegisterTService(FuncTService, Lifestyle) |
Registers the specified delegate instanceCreator that will produce instances of
type TService and will be returned when an instance of type
TService is requested. The delegate is expected to produce new instances on
each call. The instances are cached according to the supplied lifestyle.
| |
RegisterTService, TImplementation |
Registers that a new instance of TImplementation will be returned every time a
TService is requested (transient).
| |
RegisterTService, TImplementation(Lifestyle) |
Registers that an instance of TImplementation will be returned when an
instance of type TService is requested. The instance is cached according to
the supplied lifestyle.
| |
RegisterCollection(Type, IEnumerableRegistration) | Obsolete.
Registers a collection of registrations, whose instances will be resolved lazily
each time the resolved collection of serviceType is enumerated.
The underlying collection is a stream that will return individual instances based on their
specific registered lifestyle, for each call to Current.
The order in which the types appear in the collection is the exact same order that the items were
supplied to this method, i.e the resolved collection is deterministic.
| |
RegisterCollection(Type, IEnumerableAssembly) | Obsolete.
Registers all concrete, non-generic types (both public and internal) that are defined in the given
set of assemblies and that implement the given serviceType
with a default lifestyle and register them as a collection of serviceType.
Unless overridden using a custom
LifestyleSelectionBehavior, the
default lifestyle is Transient.
Composites,
decorators and
generic type definitions
will be excluded from registration.
| |
RegisterCollection(Type, IEnumerableType) | Obsolete.
Registers a collection of serviceTypes, whose instances will be resolved lazily
each time the resolved collection of serviceType is enumerated.
The underlying collection is a stream that will return individual instances based on their
specific registered lifestyle, for each call to Current.
The order in which the types appear in the collection is the exact same order that the items were
supplied to this method, i.e the resolved collection is deterministic.
| |
RegisterCollection(Type, IEnumerable) | Obsolete.
Registers a dynamic (container uncontrolled) collection of elements of type
serviceType. A call to GetAllInstancesTService will return the
containerUncontrolledCollection itself, and updates to the collection will be
reflected in the result. If updates are allowed, make sure the collection can be iterated safely
if you're running a multi-threaded application.
| |
RegisterCollection(Type, Assembly) | Obsolete.
Registers all concrete, non-generic types (both public and internal) that are defined in the given
set of assemblies and that implement the given serviceType
with a default lifestyle and register them as a collection of serviceType.
Unless overridden using a custom
LifestyleSelectionBehavior, the
default lifestyle is Transient.
Composites,
decorators and
generic type definitions
will be excluded from registration.
| |
RegisterCollectionTService(IEnumerableAssembly) | Obsolete.
Registers all concrete, non-generic types (both public and internal) that are defined in the given
set of assemblies and that implement the given TService
with a default lifestyle and register them as a collection of TService.
Unless overridden using a custom
LifestyleSelectionBehavior, the
default lifestyle is Transient.
| |
RegisterCollectionTService(IEnumerableType) | Obsolete.
Registers a collection of serviceTypes, whose instances will be resolved lazily
each time the resolved collection of TService is enumerated.
The underlying collection is a stream that will return individual instances based on their
specific registered lifestyle, for each call to Current.
The order in which the types appear in the collection is the exact same order that the items were
supplied to this method, i.e the resolved collection is deterministic.
| |
RegisterCollectionTService(IEnumerableTService) | Obsolete.
Registers a dynamic (container-uncontrolled) collection of elements of type
TService. A call to GetAllInstancesTService will return the
containerUncontrolledCollection itself, and updates to the collection will be
reflected in the result. If updates are allowed, make sure the collection can be iterated safely
if you're running a multi-threaded application.
| |
RegisterCollectionTService(TService) | Obsolete.
Registers a collection of singleton elements of type TService.
| |
RegisterCollectionTService(IEnumerableRegistration) | Obsolete.
Registers a collection of registrations, whose instances will be resolved lazily
each time the resolved collection of TService is enumerated.
The underlying collection is a stream that will return individual instances based on their
specific registered lifestyle, for each call to Current.
The order in which the types appear in the collection is the exact same order that the items were
supplied to this method, i.e the resolved collection is deterministic.
| |
RegisterConditional(Type, Registration, PredicatePredicateContext) |
Conditionally registers that registration will be used every time a
serviceType is requested and where the supplied predicate
returns true. The predicate will only be evaluated a finite number of times; the predicate is
unsuited for making decisions based on runtime conditions.
| |
RegisterConditional(Type, Type, PredicatePredicateContext) |
Conditionally registers that a new instance of implementationType will be
returned every time a serviceType is requested (transient) and where the
supplied predicate returns true. The predicate will only be evaluated a finite
number of times; the predicate is unsuited for making decisions based on runtime conditions.
| |
RegisterConditional(Type, FuncTypeFactoryContext, Type, Lifestyle, PredicatePredicateContext) |
Conditionally registers that an instance of the type returned from
implementationTypeFactory will be returned every time a
serviceType is requested and where the supplied predicate
returns true. The instance is cached according to the supplied
lifestyle. Both the predicate and
implementationTypeFactory will only be evaluated a finite number of times;
they unsuited for making decisions based on runtime conditions.
| |
RegisterConditional(Type, Type, Lifestyle, PredicatePredicateContext) |
Conditionally registers that an instance of implementationType will be
returned every time a serviceType is requested and where the supplied
predicate returns true. The instance is cached according to the supplied
lifestyle. The predicate will only be evaluated a finite number of times; the
predicate is unsuited for making decisions based on runtime conditions.
| |
RegisterConditionalTService(Registration, PredicatePredicateContext) |
Conditionally registers that registration will be used every time a
TService requested and where the supplied predicate
returns true. The predicate will only be evaluated a finite number of times; the predicate is
unsuited for making decisions based on runtime conditions.
| |
RegisterConditionalTService, TImplementation(PredicatePredicateContext) |
Conditionally registers that a new instance of TImplementation will be
returned every time a TService is requested (transient) and where the
supplied predicate returns true. The predicate will only be evaluated a finite
number of times; the predicate is unsuited for making decisions based on runtime conditions.
| |
RegisterConditionalTService, TImplementation(Lifestyle, PredicatePredicateContext) |
Conditionally registers that an instance of TImplementation will be
returned every time a TService is requested and where the supplied
predicate returns true. The instance is cached according to the supplied
lifestyle. The predicate will only be evaluated a finite number of times; the
predicate is unsuited for making decisions based on runtime conditions.
| |
RegisterDecorator(Type, Type) |
Ensures that the supplied decoratorType decorator is returned, wrapping the
original registered serviceType, by injecting that service type into the
constructor of the supplied decoratorType. Multiple decorators may be applied
to the same serviceType. Decorators can be applied to both open, closed, and
non-generic service types. By default, a new decoratorType instance will be
returned on each request (according the Transient lifestyle),
independently of the lifestyle of the wrapped service.
| |
RegisterDecorator(Type, Type, Lifestyle) |
Ensures that the supplied decoratorType decorator is returned and cached with
the given lifestyle, wrapping the original registered
serviceType, by injecting that service type into the constructor of the
supplied decoratorType. Multiple decorators may be applied to the same
serviceType. Decorators can be applied to both open, closed, and non-generic
service types.
| |
RegisterDecorator(Type, Type, PredicateDecoratorPredicateContext) |
Ensures that the supplied decoratorType decorator is returned when the supplied
predicate returns true, wrapping the original registered
serviceType, by injecting that service type into the constructor of the
supplied decoratorType. Multiple decorators may be applied to the same
serviceType. Decorators can be applied to both open, closed, and non-generic
service types. By default, a new decoratorType instance will be returned on
each request (according the Transient lifestyle),
independently of the lifestyle of the wrapped service.
| |
RegisterDecorator(Type, FuncDecoratorPredicateContext, Type, Lifestyle, PredicateDecoratorPredicateContext) |
Ensures that the decorator type that is returned from decoratorTypeFactory is
supplied when the supplied predicate returns true and cached with the given
lifestyle, wrapping the original registered serviceType, by
injecting that service type into the constructor of the decorator type that is returned by the
supplied decoratorTypeFactory.
Multiple decorators may be applied to the same serviceType. Decorators can be
applied to both open, closed, and non-generic service types.
| |
RegisterDecorator(Type, Type, Lifestyle, PredicateDecoratorPredicateContext) |
Ensures that the supplied decoratorType decorator is returned when the supplied
predicate returns true and cached with the given
lifestyle, wrapping the original registered serviceType, by
injecting that service type into the constructor of the supplied decoratorType.
Multiple decorators may be applied to the same serviceType. Decorators can be
applied to both open, closed, and non-generic service types.
| |
RegisterDecoratorTService, TDecorator |
Ensures that the supplied TDecorator decorator is returned, wrapping the
original registered TService, by injecting that service type into the
constructor of the supplied TDecorator. Multiple decorators may be applied
to the same TService. By default, a new TDecorator
instance will be returned on each request (according the
Transient lifestyle), independently of the lifestyle of the
wrapped service.
| |
RegisterDecoratorTService, TDecorator(Lifestyle) |
Ensures that the supplied TDecorator decorator is returned and cached with
the given lifestyle, wrapping the original registered
TService, by injecting that service type into the constructor of the
supplied TDecorator. Multiple decorators may be applied to the same
TService. Decorators can be applied to both open, closed, and non-generic
service types.
| |
RegisterInitializer(ActionInstanceInitializationData, PredicateInitializerContext) |
Registers an ActionT delegate that runs after the
creation of instances for which the supplied predicate returns true. Please
note that only instances that are created by the container can be initialized this way.
| |
RegisterInitializerTService(ActionTService) |
Registers an ActionT delegate that runs after the creation of instances that
implement or derive from the given TService. Please note that only instances
that are created by the container (using constructor injection) can be initialized this way.
| |
RegisterInstance(Type, Object) |
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.
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
RegisterSingleton(Type, Func<object>).
| |
RegisterInstanceTService(TService) |
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
RegisterSingleton<TService>(Func<TService>).
| |
RegisterSingleton(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.
| |
RegisterSingleton(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.
| |
RegisterSingleton(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.
| |
RegisterSingleton(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.
| |
RegisterSingleton(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.
| |
RegisterSingletonTConcrete |
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.
| |
RegisterSingletonTService(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.
| |
RegisterSingletonTService(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.
| |
RegisterSingletonTService, 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.
| |
ToString | Returns a string that represents the current object. (Inherited from ApiObject.) | |
Verify |
Verifies and diagnoses this Container instance. This method will call all registered
delegates, iterate registered collections and throws an exception if there was an error.
| |
Verify(VerificationOption) |
Verifies the Container. This method will call all registered delegates,
iterate registered collections and throws an exception if there was an error.
|
Extension Methods
Name | Description | |
---|---|---|
AppendToCollection(Type, Registration) | Overloaded.
Allows appending new registrations to existing registrations made using one of the
Collections.Register overloads.
(Defined by AdvancedExtensions.) | |
AppendToCollection(Type, Type) | Overloaded.
Allows appending new registrations to existing registrations made using one of the
Collections.Register overloads.
(Defined by AdvancedExtensions.) | |
EnableHttpRequestMessageTracking |
Makes the current HttpRequestMessage resolvable by calling
GetCurrentHttpRequestMessage.
(Defined by SimpleInjectorWebApiExtensions.) | |
GetCurrentHttpRequestMessage |
Retrieves the HttpRequestMessage instance for the current request.
(Defined by SimpleInjectorWebApiExtensions.) | |
GetItem |
Retrieves an item from the container stored by the given key or null when no
item is stored by that key.
(Defined by AdvancedExtensions.) | |
GetOrSetItemT |
Adds an item by the given key in the container by using the specified function,
if the key does not already exist. This operation is atomic.
(Defined by AdvancedExtensions.) | |
IsLocked |
Determines whether the specified container is locked making any new registrations. The container
is automatically locked when GetInstance is called for the
first time.
(Defined by AdvancedExtensions.) | |
IsVerifying | Determines whether the specified container is currently verifying its configuration. (Defined by AdvancedExtensions.) | |
RegisterWebApiControllers(HttpConfiguration) | Overloaded.
Registers the Web API IHttpController types that available for the application. This
method uses the configured IAssembliesResolver and
IHttpControllerTypeResolver to determine which controller types to register.
(Defined by SimpleInjectorWebApiExtensions.) | |
RegisterWebApiControllers(HttpConfiguration, Assembly) | Overloaded.
Registers the Web API IHttpController types that available for the application. This
method uses the configured IHttpControllerTypeResolver to determine which controller
types to register.
(Defined by SimpleInjectorWebApiExtensions.) | |
RegisterWebApiControllers(HttpConfiguration, IEnumerableAssembly) | Overloaded.
Registers the Web API IHttpController types that available for the application. This
method uses the configured IHttpControllerTypeResolver to determine which controller
types to register.
(Defined by SimpleInjectorWebApiExtensions.) | |
SetItem |
Stores an item by the given key in the container.
(Defined by AdvancedExtensions.) |
Explicit Interface Implementations
Name | Description | |
---|---|---|
IServiceProviderGetService | Gets the service object of the specified type. |
See Also