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); }
public static T Build <T>(this DIContainer container, string name = null) where T : class { return(container.Build(typeof(T), name) as T); }