public void Singleton() { IContainer container = new Container(); container.Set(typeof(IRobot)).To(typeof(AttackRobot)).Singleton(); container.Set(typeof(IPilot)).To(typeof(Pilot)); AttackRobot robot = container.Get(typeof(IRobot)) as AttackRobot; robot.SetWeapon("drill punch"); string result = robot.Attack(); Assert.AreEqual("attack with the drill punch", result); AttackRobot robot2 = container.Get(typeof(IRobot)) as AttackRobot; result = robot2.Attack(); Assert.AreEqual("attack with the drill punch", result); Assert.AreEqual(true, robot.Equals(robot2)); }
private void PostCreateRobot(Type serviceType, object instance, IContainer container, ParameterList parameterList) { AttackRobot robot = instance as AttackRobot; robot.SetWeapon("drill punch"); }