Mugen Injection [Relationship types]
Dependencies using the types below are interpreted specially by MugenInjection. For example, when MugenInjection is injecting a constructor parameter of type IEnumerable<IBeta> it will not look for a component that supplies IEnumerable<IBeta>. Instead, the container will find all implementations of IBeta and inject all of them.
Implicit relationship types
Relationship | Type | Meaning |
---|---|---|
Alpha needs Beta | Beta | Dependency |
Alpha needs Beta at some point in the future | Lazy<Beta>, CustomLazy<Beta> | Delayed instantiation |
Alpha needs Beta until some point in the future | Managed<Beta>, CustomManaged<Beta> | Controlled lifetime |
Alpha needs Beta until some point in the future | UoW<Beta>, CustomUoW<Beta> | Controlled lifetime |
Alpha needs to create instances of Beta | Func<Beta>, CustomFunc<Beta> | Dynamic instantiation |
Alpha needs to create instances of Beta with P1, P2 parameters | Func<P1, P2, Beta> | Dynamic instantiation with parameters |
Alpha needs to create instances of Beta with special parameters | Func<ISettings, Beta> | Dynamic instantiation with special parameters |
Alpha needs all instances of Beta | IEnumerable<Beta>, IList<Beta>, List<Beta>, ICollection<Beta>, ICustomCollection<Beta> | Collection |
Alpha needs Beta with settings | WithSettings<Beta>, WithCustomSettings<Beta> | Metadata interrogation |
To override this default behaviour it is still possible to register explicit implementations of these types.
Composing relationship types
Relationship types can be composed:IEnumerable<Func<Managed<Beta>>>
- All implementations, of
- Factories, that return
- Lifetime-controlled
- Beta services