void SetupContainer() { container = new Container(); container.Bind <IGameObjectFactory>().AsSingle <GameObjectFactory>(new GameObjectFactory(container)); container.Bind <IMonsterCounter>().AsSingle <UnderAttackSystem>(); container.Bind <WeaponPresenter>().ToFactory(new MultiProvider <WeaponPresenter>()); container.Bind <MonsterPresenter>().ToFactory(new MultiProvider <MonsterPresenter>()); container.BindSelf <UnderAttackSystem>(); container.BindSelf <PathController>(); container.BindSelf <MonsterSpawner>(); }
void SetupContainer() { container = new Container(); //interface is bound to a specific instance container.Bind <IGameObjectFactory>().AsSingle(new GameObjectFactory(this)); //interfaces are bound to specific implementations, the same instance will be used once created container.Bind <IMonsterCounter>().AsSingle <MonsterCountHolder>(); container.Bind <IMonsterCountHolder>().AsSingle <MonsterCountHolder>(); //once the dependency is requested, a new instance will be created container.Bind <WeaponPresenter>().ToFactory(new MultiProvider <WeaponPresenter>()); container.Bind <MonsterPresenter>().ToFactory(new MultiProvider <MonsterPresenter>()); container.Bind <MonsterPathFollower>().ToFactory(new MultiProvider <MonsterPathFollower>()); //once requested, the same instance will be used container.BindSelf <UnderAttackSystem>(); container.BindSelf <PathController>(); }