private bool resolveSiteBreadthFirst(IInjectionSite site, List <GameObject> rootNodes) { foreach (var gameObject in breadthFirstTraversal(rootNodes)) { var source = findInjectionSource(site, gameObject); if (source != null) { site.Resolve(source); return(true); } } if (site.Required) { Debug.LogWarning("Unable to find dependency source from anywhere (used breadth-first strategy)"); } return(false); }
private bool resolveSiteFromParents(IInjectionSite site, MonoBehaviour script) { // search for source upwards from script object foreach (var gameObject in ancestors(script.gameObject)) { var source = findInjectionSource(site, gameObject); if (source != null) { site.Resolve(source); return(true); } } if (site.Required) { Debug.LogWarning("Unable to find dependency source in parents"); } return(false); }
private bool resolveSiteFromChildren(IInjectionSite site, MonoBehaviour script) { IEnumerable <GameObject> children; switch (site.SearchMethod) { case Search.Breadth: children = breadthFirstTraversal(new List <GameObject> { script.gameObject }); break; case Search.Depth: children = depthFirstTraversal(new List <GameObject> { script.gameObject }); break; default: throw new ArgumentOutOfRangeException(); } foreach (var gameObject in children) { var source = findInjectionSource(site, gameObject); if (source != null) { site.Resolve(source); return(true); } } if (site.Required) { Debug.LogWarning("Unable to find dependency source in children"); } return(false); }