100coding
3/29/2017 - 8:31 AM

'Hello World Example For Sub-Containers/Facade' example in Zenject Tutorial

'Hello World Example For Sub-Containers/Facade' example in Zenject Tutorial

using Zenject;

public class TestInstaller : MonoInstaller<TestInstaller>
{
    public override void InstallBindings()
    {
        Container.BindInterfacesAndSelfTo<GameController>().AsSingle();
        Container.Bind<Greeter>().FromSubContainerResolve().ByMethod(Install_greeter).AsSingle();
    }

    private void Install_greeter(DiContainer sub_container)
    {
        sub_container.Bind<Greeter>().AsSingle();
        sub_container.BindInstance("Hello world!");
    }
}