using System;
using System.Linq;
using DryIoc;
public class Program
{
public static void Main()
var container = new Container();
container.Register<LeafOne>(Reuse.Singleton);
container.Register<LeafTwo>(Reuse.Singleton);
// the keys are required in the DryIoc <=4.3.4 because RegisterMapping uses the IfAlreadyRegistered.Keep by default,
// keeping the first Base registration and rejecting the second
//container.RegisterMapping<Base, LeafOne>(serviceKey: 1);
//container.RegisterMapping<Base, LeafTwo>(serviceKey: 2);
// Works too
//container.RegisterDelegate<Base>(r => r.Resolve<LeafOne>());
//container.RegisterDelegate<Base>(r => r.Resolve<LeafTwo>());
// Works too - ant it is more preferable because it won't use the service locator internal Resolve call
//container.RegisterDelegate<LeafOne, Base>(x => x);
//container.RegisterDelegate<LeafTwo, Base>(x => x);
var bases = container.ResolveMany<Base>().ToArray();
Console.WriteLine(bases.Length);
}
abstract class Base {};
class LeafOne : Base {};
class LeafTwo : Base {};