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 BindExecutionOrder <T>( this DiContainer container, int order) { container.BindExecutionOrder(typeof(T), order); }