void InstallBindings(List <MonoBehaviour> injectableMonoBehaviours) { _container.Bind(typeof(Context), typeof(SceneContext)).To <SceneContext>().FromInstance(this); _container.BindInterfacesTo <SceneContextRegistryAdderAndRemover>().AsSingle(); // Add to registry first and remove from registry last _container.BindExecutionOrder <SceneContextRegistryAdderAndRemover>(-1); foreach (var decoratorContext in _decoratorContexts) { decoratorContext.InstallDecoratorSceneBindings(); } InstallSceneBindings(injectableMonoBehaviours); _container.Bind(typeof(SceneKernel), typeof(MonoKernel)) .To <SceneKernel>().FromNewComponentOn(gameObject).AsSingle().NonLazy(); _container.Bind <ZenjectSceneLoader>().AsSingle(); if (ExtraBindingsInstallMethod != null) { ExtraBindingsInstallMethod(_container); // Reset extra bindings for next time we change scenes ExtraBindingsInstallMethod = null; } // Always install the installers last so they can be injected with // everything above foreach (var decoratorContext in _decoratorContexts) { decoratorContext.InstallDecoratorInstallers(); } InstallInstallers(); foreach (var decoratorContext in _decoratorContexts) { decoratorContext.InstallLateDecoratorInstallers(); } if (ExtraBindingsLateInstallMethod != null) { ExtraBindingsLateInstallMethod(_container); // Reset extra bindings for next time we change scenes ExtraBindingsLateInstallMethod = null; } }
public static void InstallBindingsCore(DiContainer container) { // domain. container.BindInterfacesTo <SceneManager>().AsCached(); // presentation. container.BindExecutionOrder <GameTimer>(-1000000); container.BindInterfacesTo <GameTimer>().AsCached(); // data. container.BindInterfacesTo <FileSave>().AsCached().WithArguments(Application.temporaryCachePath); container.Bind <CacheUserStore>().AsCached(); container.Bind <UserStore>().AsCached(); container.Bind <UserTranslator>().AsCached(); container.Bind <HiScoreTranslator>().AsCached(); // test. container.BindUseCase <TestUserUseCase, TestUserUseCaseFactory, TestUserUseCase.IFactory>(); container.BindRepository <TestUserRepository>(); container.Bind <TestUserNameStore>().AsCached(); }