/// <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); } }
private CachedComponentResolver RentResolver() => ResolverPool.Rent(gameObject, _dependencySource);