示例#1
0
        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);
        }
示例#2
0
文件: Di.cs 项目: Delt06/di-framework
        /// <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);
            }
        }
示例#3
0
        public void Resolve()
        {
            if (_resolved)
            {
                return;
            }

            _resolved = true;

            var resolver = RentResolver();

            resolver.Resolve();
            ResolverPool.Return(resolver);

            if (_destroyWhenFinished)
            {
                Destroy(this);
            }
        }
示例#4
0
 private CachedComponentResolver RentResolver() => ResolverPool.Rent(gameObject, _dependencySource);