Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Registers the supplied types by using the specified rules for name, lifetime manager, injection members, and registration types.
Namespace: Microsoft.Practices.Unity
Assembly: Microsoft.Practices.Unity (in Microsoft.Practices.Unity.dll) Version: 3.0.0.0 (3.0.1304.0)
Syntax
public static IUnityContainer RegisterTypes(
this IUnityContainer container,
IEnumerable<Type> types,
Func<Type, IEnumerable<Type>> getFromTypes = null,
Func<Type, string> getName = null,
Func<Type, LifetimeManager> getLifetimeManager = null,
Func<Type, IEnumerable<InjectionMember>> getInjectionMembers = null,
bool overwriteExistingMappings = false
)
'Declaration
<ExtensionAttribute>
Public Shared Function RegisterTypes (
container As IUnityContainer,
types As IEnumerable(Of Type),
Optional getFromTypes As Func(Of Type, IEnumerable(Of Type)) = Nothing,
Optional getName As Func(Of Type, String) = Nothing,
Optional getLifetimeManager As Func(Of Type, LifetimeManager) = Nothing,
Optional getInjectionMembers As Func(Of Type, IEnumerable(Of InjectionMember)) = Nothing,
Optional overwriteExistingMappings As Boolean = false
) As IUnityContainer
public:
[ExtensionAttribute]
static IUnityContainer^ RegisterTypes(
IUnityContainer^ container,
IEnumerable<Type^>^ types,
Func<Type^, IEnumerable<Type^>^>^ getFromTypes = nullptr,
Func<Type^, String^>^ getName = nullptr,
Func<Type^, LifetimeManager^>^ getLifetimeManager = nullptr,
Func<Type^, IEnumerable<InjectionMember^>^>^ getInjectionMembers = nullptr,
bool overwriteExistingMappings = false
)
Parameters
- container
Type: Microsoft.Practices.Unity.IUnityContainer
The container to configure.
- types
Type: System.Collections.Generic.IEnumerable<Type>
The types to register. The methods in the AllClasses class can be used to scan assemblies to get types, and further filtering can be performed using LINQ queries.
- getFromTypes (Optional)
Type: System.Func<Type, IEnumerable<Type>>
A function that gets the types that will be requested for each type to configure. It can be a method from the WithMappings class or a custom function. Defaults to no registration types, and registers only the supplied types.
- getName (Optional)
Type: System.Func<Type, String>
A function that gets the name to use for the registration of each type. It can be a method from the WithName or a custom function. Defaults to no name.
- getLifetimeManager (Optional)
Type: System.Func<Type, LifetimeManager>
A function that gets the LifetimeManager for the registration of each type. It can be a method from the WithLifetime class or a custom function. Defaults to no lifetime management.
- getInjectionMembers (Optional)
Type: System.Func<Type, IEnumerable<InjectionMember>>
A function that gets the additional InjectionMember objects for the registration of each type. Defaults to no injection members.
- overwriteExistingMappings (Optional)
Type: System.Boolean
truetrue (True in Visual Basic) to overwrite existing mappings; otherwise, falsefalse (False in Visual Basic). Defaults to falsefalse (False in Visual Basic).
Return Value
Type: IUnityContainer
The container that this method was called on.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IUnityContainer. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
Exception | Condition |
---|---|
System.ArgumentException | A new registration would overwrite an existing mapping and overwriteExistingMappings is falsefalse (False in Visual Basic). |
See Also
UnityContainerRegistrationByConventionExtensions Class