-
Notifications
You must be signed in to change notification settings - Fork 29
Projecting Components
The second step is to select the components for which you want to create a binding. This can be compared to the To syntaxes of the single component binding syntax. This step consists of two sub steps.
First you have to select the type of the components:
| Method | Description |
|---|---|
SelectAllClasses() |
This is the method that is used in almost every case. It selects all none abstract classes. |
SelectAllIncludingAbstractClasses() |
This method selects all classes including abstract ones. |
SelectAllAbstractClasses() |
This method selects just abstract classes. |
SelectAllInterfaces() |
This method selects all interfaces. |
SelectAllTypes() |
Selects all types (classes, interfaces, structs, enums, primitive types). |
Select(Func<Type, bool> filter) |
Incase none of the previous method fit for you, this method can be used to specify exactly which types you are interested in. The function is called for every type. If you want to select a type that you have to return true. Otherwise return false. |
Notes: SelectAllIncludingAbstractClasses, SelectAllAbstractClasses and SelectAllInterfaces
Since you can't bind to abstract classes or interfaces these overloads make only sense in combination with a binding generator that generates the implementation on the fly (e.g. BindToFactory)
The second step is to filter the currently selected component types by chaining some of the following methods:
| Method | Description |
|---|---|
InNamespaces(IEnumerable<string> namespaces)InNamespaces(params string[] namespaces)
|
Selects the types in the specified namespaces. |
InNamespaceOf<T>()InNamespaceOf(params Type[] types)
|
Selects the types in the same namespace as the given types. |
NotInNamespaces(IEnumerable<string> namespaces)NotInNamespaces(params string[] namespaces)
|
Selects all types except those that are in one of the given namespaces. |
NotInNamespaceOf<T>()NotInNamespaceOf(params Type[] types)
|
Selects all types not in same namespaces as the given type. |
InheritedFromAny(IEnumerable<Type> types)InheritedFromAny(params Type[] types)InheritedFrom<T>()
|
Selects the types that are inherited from any of the given types. |
WithAttribute<T>()WithAttribute(Type attributeType)WithAttribute<T>(Func<T, bool> predicate)
|
Selects the types that have the specified attribute. In case a predicate is pecified the types are filtered additionally using the given predicate. |
WithoutAttribute<T>()WithoutAttribute(Type attributeType)WithoutAttribute<T>(Func<T, bool> predicate)
|
Selects the types that do not have the specified attribute. In case a predicate is pecified the types are filtered additionally using the given predicate. |
WhichAreGeneric() |
Selects all generic types. |
WhichAreNotGeneric() |
Selects all none generic types. |
StartingWith(string prefix) |
Selects types with the given prefix in their name. |
EndingWith(string postfix) |
Selects types with the given postfix in their name. |
Once you have selected the components you want to create bindings for you have the option to include or excluce some types explicitly. This can be done using one of the following methods:
| Method | Description |
|---|---|
Including<T>() |
Includes the specified type. |
Including(params Type[] types) |
Includes the specified types. |
Including(IEnumerable<Type> types) |
Includes the specified types. |
Excluding<T>() |
Excludes the specified type. |
Excluding(params Type[] types) |
Excludes the specified types. |
Excluding(IEnumerable<Type> types) |
Excludes the specified types. |
Continue Reading: Projecting Services to Bind
Back: Projecting Assemblies