static void Main(string[] args) { AppKernel = new StandardKernel(new WeaponNinjectModule()); var warrior = AppKernel.Get <Warrior>(); warrior.Kill(); var otherWarrior = new OtherWarrior(); otherWarrior.Kill(); var anotherWarrior = AppKernel.Get <AnotherWarrior>(); anotherWarrior.Kill(); Console.ReadLine(); }
static void Main(string[] args) { Container = new UnityContainer(); Container.RegisterType(typeof(IWeapon), typeof(Bazuka)); var serviceProvider = new UnityServiceLocator(Container); ServiceLocator.SetLocatorProvider(() => serviceProvider); var warrior = Container.Resolve <Warrior>(); warrior.Kill(); var otherWarrior = new OtherWarrior(); otherWarrior.Kill(); Console.ReadLine(); }