-
Notifications
You must be signed in to change notification settings - Fork 10
Multi resolution
Peter Csajtai edited this page Feb 16, 2017
·
13 revisions
Stashbox allows you to resolve all the available services bound to an interface or base class.
container.RegisterType<ICreature, Dwarf>("Bruenor");
container.RegisterType<ICreature, Drow>("Drizzt");
container.RegisterType<ICreature, Human>("Catti-brie");
container.RegisterType<ICreature, Barbarian>("Wulfgar");
container.RegisterType<ICreature, Halfling>("Regis");
Then you can get all of your services by calling the ResolveAll()
method.
var companionsOfTheHall = container.ResolveAll<ICreature>();
Or you can just let Stashbox to do the work for you.
class CompanionsOfTheHall
{
public CompanionsOfTheHall(IEnumerable<ICreature> members)
{
//...
}
//or
public CompanionsOfTheHall(ICreature[] members)
{
//...
}
//or
public CompanionsOfTheHall(ICollection<ICreature> members)
{
//...
}
//etc...
}
//or
var companions = container.Resolve<IEnumerable<ICreature>>();
//etc...
- Service registration
- Factory registration
- Assembly registration
- Composition
- Fluent registration api
- Service resolution
- Resolution by attributes
- Conventional resolution
- Delegate resolution
- Conditional resolution
- Multi resolution
- Lifetimes
- Generics
- Generic wrappers
- Decorators
- Resolvers
- Scopes
- Container configuration
- Container diagnostics
- Exceptions