public bool CanBeResolvedSafe(MonoBehaviour component, Type type, out DependencySource actualSource) { var resolver = RentResolver(); var canBeResolvedSafe = resolver.CanBeResolvedSafe(component, type, out actualSource); ResolverPool.Return(resolver); return(canBeResolvedSafe); }
/// <summary> /// Inject dependencies into components of the provided Game Object (from the specified sources). /// </summary> /// <param name="gameObject">Injected Game Object.</param> /// <param name="sources">Sources to get dependencies from.</param> /// <exception cref="ArgumentNullException">If <paramref name="gameObject"/> is null.</exception> public static void Inject([NotNull] GameObject gameObject, DependencySource sources) { if (gameObject == null) { throw new ArgumentNullException(nameof(gameObject)); } var resolver = ResolverPool.Rent(gameObject, sources); try { resolver.Resolve(); } finally { ResolverPool.Return(resolver); } }
public void Resolve() { if (_resolved) { return; } _resolved = true; var resolver = RentResolver(); resolver.Resolve(); ResolverPool.Return(resolver); if (_destroyWhenFinished) { Destroy(this); } }
private CachedComponentResolver RentResolver() => ResolverPool.Rent(gameObject, _dependencySource);