static void Main(string[] args)
        {
            var container = new DIContainer();

            container.Register(typeof(Bread), typeof(SesameSeedBun));
            container.Register(typeof(Cheese), typeof(SwissCheese));
            container.Register(typeof(Sauce), typeof(Ketchup));
            container.Register(typeof(Patty), typeof(ChickenPatty));
            var burger = container.Build(typeof(Burger));

            Console.ReadKey(true);
        }
Beispiel #2
0
 public static DIContainer Register <TContract, TImpl>(this DIContainer container, string name = null)
     where TImpl : TContract
 {
     container.Register(typeof(TContract), typeof(TImpl), name);
     return(container);
 }