Ejemplo n.º 1
0
        public static IEnumerable <ZenjectResolveException> ValidateInstallers(SceneCompositionRoot compRoot, GameObject rootGameObject)
        {
            var globalContainer = GlobalCompositionRoot.CreateContainer(true, null);
            var container       = compRoot.CreateContainer(true, globalContainer, new List <IInstaller>());

            foreach (var error in container.ValidateResolve(
                         new InjectContext(container, typeof(IFacade), null)))
            {
                yield return(error);
            }

            var injectedGameObjects = rootGameObject != null?rootGameObject.GetComponentsInChildren <Transform>() : GameObject.FindObjectsOfType <Transform>();

            // Also make sure we can fill in all the dependencies in the built-in scene
            foreach (var curTransform in injectedGameObjects)
            {
                foreach (var monoBehaviour in curTransform.GetComponents <MonoBehaviour>())
                {
                    if (monoBehaviour == null)
                    {
                        // fiBackupSceneStorage shows up sometimes for reasons I don't understand
                        // but it's normal so ignore
                        if (curTransform.name != "fiBackupSceneStorage")
                        {
                            Log.Warn("Found null MonoBehaviour on " + curTransform.name);
                        }

                        continue;
                    }

                    foreach (var error in container.ValidateObjectGraph(monoBehaviour.GetType()))
                    {
                        yield return(error);
                    }
                }
            }

            foreach (var installer in globalContainer.InstalledInstallers.Concat(container.InstalledInstallers).OfType <IValidatable>())
            {
                foreach (var error in installer.Validate())
                {
                    yield return(error);
                }
            }

            foreach (var error in container.ValidateValidatables())
            {
                yield return(error);
            }
        }
Ejemplo n.º 2
0
        public static IEnumerable<ZenjectResolveException> ValidateInstallers(SceneCompositionRoot compRoot, GameObject rootGameObject)
        {
            var globalContainer = GlobalCompositionRoot.CreateContainer(true, null);
            var container = compRoot.CreateContainer(true, globalContainer, new List<IInstaller>());

            foreach (var error in container.ValidateResolve(
                new InjectContext(container, typeof(IFacade), null)))
            {
                yield return error;
            }

            var injectedGameObjects = rootGameObject != null ? rootGameObject.GetComponentsInChildren<Transform>() : GameObject.FindObjectsOfType<Transform>();

            // Also make sure we can fill in all the dependencies in the built-in scene
            foreach (var curTransform in injectedGameObjects)
            {
                foreach (var monoBehaviour in curTransform.GetComponents<MonoBehaviour>())
                {
                    if (monoBehaviour == null)
                    {
                        // fiBackupSceneStorage shows up sometimes for reasons I don't understand
                        // but it's normal so ignore
                        if (curTransform.name != "fiBackupSceneStorage")
                        {
                            Log.Warn("Found null MonoBehaviour on " + curTransform.name);
                        }

                        continue;
                    }

                    foreach (var error in container.ValidateObjectGraph(monoBehaviour.GetType()))
                    {
                        yield return error;
                    }
                }
            }

            foreach (var installer in globalContainer.InstalledInstallers.Concat(container.InstalledInstallers).OfType<IValidatable>())
            {
                foreach (var error in installer.Validate())
                {
                    yield return error;
                }
            }

            foreach (var error in container.ValidateValidatables())
            {
                yield return error;
            }
        }
Ejemplo n.º 3
0
        public static IEnumerable <ZenjectResolveException> ValidateInstallers(SceneCompositionRoot compRoot)
        {
            var globalContainer = GlobalCompositionRoot.CreateContainer(true, null);
            var container       = compRoot.CreateContainer(true, globalContainer, new List <IInstaller>());

            foreach (var error in container.ValidateResolve(new InjectContext(container, typeof(IDependencyRoot), null)))
            {
                yield return(error);
            }

            // Also make sure we can fill in all the dependencies in the built-in scene
            foreach (var curTransform in compRoot.GetComponentsInChildren <Transform>())
            {
                foreach (var monoBehaviour in curTransform.GetComponents <MonoBehaviour>())
                {
                    if (monoBehaviour == null)
                    {
                        Log.Warn("Found null MonoBehaviour on " + curTransform.name);
                        continue;
                    }

                    foreach (var error in container.ValidateObjectGraph(monoBehaviour.GetType()))
                    {
                        yield return(error);
                    }
                }
            }

            foreach (var installer in globalContainer.InstalledInstallers.Concat(container.InstalledInstallers))
            {
                if (installer is IValidatable)
                {
                    foreach (var error in ((IValidatable)installer).Validate())
                    {
                        yield return(error);
                    }
                }
            }

            foreach (var error in container.ValidateValidatables())
            {
                yield return(error);
            }
        }
Ejemplo n.º 4
0
        public static IEnumerable<ZenjectResolveException> ValidateInstallers(SceneCompositionRoot compRoot)
        {
            var globalContainer = GlobalCompositionRoot.CreateContainer(true, null);
            var container = compRoot.CreateContainer(true, globalContainer, new List<IInstaller>());

            foreach (var error in container.ValidateResolve(new InjectContext(container, typeof(IFacade), null)))
            {
                yield return error;
            }

            // Also make sure we can fill in all the dependencies in the built-in scene
            foreach (var curTransform in compRoot.GetComponentsInChildren<Transform>())
            {
                foreach (var monoBehaviour in curTransform.GetComponents<MonoBehaviour>())
                {
                    if (monoBehaviour == null)
                    {
                        Log.Warn("Found null MonoBehaviour on " + curTransform.name);
                        continue;
                    }

                    foreach (var error in container.ValidateObjectGraph(monoBehaviour.GetType()))
                    {
                        yield return error;
                    }
                }
            }

            foreach (var installer in globalContainer.InstalledInstallers.Concat(container.InstalledInstallers))
            {
                if (installer is IValidatable)
                {
                    foreach (var error in ((IValidatable)installer).Validate())
                    {
                        yield return error;
                    }
                }
            }

            foreach (var error in container.ValidateValidatables())
            {
                yield return error;
            }
        }