static IEnumerable <ZenjectResolveException> ValidateInstallers(CompositionRoot compRoot) { var container = new DiContainer(); container.Bind <CompositionRoot>().ToSingle(compRoot); var allInstallers = new List <IInstaller>(); foreach (var installer in compRoot.Installers) { if (installer == null) { yield return(new ZenjectResolveException( "Found null installer in properties of Composition Root")); yield break; } if (installer.enabled) { installer.Container = container; container.Bind <IInstaller>().To(installer); } allInstallers.AddRange(container.InstallInstallers()); Assert.That(!container.HasBinding <IInstaller>()); } foreach (var error in container.ValidateResolve <IDependencyRoot>()) { yield return(error); } // Also make sure we can fill in all the dependencies in the built-in scene foreach (var monoBehaviour in compRoot.GetComponentsInChildren <MonoBehaviour>()) { if (monoBehaviour == null) { // Be nice to give more information here Log.Warn("Found null MonoBehaviour in scene"); continue; } foreach (var error in container.ValidateObjectGraph(monoBehaviour.GetType())) { yield return(error); } } // Validate dynamically created object graphs foreach (var installer in allInstallers) { foreach (var error in installer.ValidateSubGraphs()) { yield return(error); } } }
public IEnumerable <ZenjectResolveException> Validate() { foreach (var constructType in _typeMap.Values) { foreach (var error in _container.ValidateObjectGraph(constructType, ProvidedTypes)) { yield return(error); } } }
static IEnumerable <ZenjectResolveException> ValidateInstallers(CompositionRoot compRoot) { var container = new DiContainer(); container.Bind <CompositionRoot>().ToSingle(compRoot); foreach (var installer in compRoot.Installers) { if (installer == null) { yield return(new ZenjectResolveException( "Found null installer in properties of Composition Root")); yield break; } installer.Container = container; container.Bind <IInstaller>().To(installer); } foreach (var error in ZenUtil.ValidateInstallers(container)) { yield return(error); } // Also make sure we can fill in all the dependencies in the built-in scene foreach (var monoBehaviour in compRoot.GetComponentsInChildren <MonoBehaviour>()) { if (monoBehaviour == null) { // Be nice to give more information here Debug.LogWarning("Found null MonoBehaviour in scene"); continue; } foreach (var error in container.ValidateObjectGraph(monoBehaviour.GetType())) { yield return(error); } } }
public IEnumerable <ZenjectResolveException> Validate(params Type[] extras) { return(_container.ValidateObjectGraph <TConcrete>(extras)); }
// Helper method for ValidateSubGraphs protected IEnumerable <ZenjectResolveException> Validate <T>(params Type[] extraTypes) { return(_container.ValidateObjectGraph <T>(extraTypes)); }