Exemple #1
0
        /// <summary>
        /// Inject and prepare GameObjects that reside in the scene
        /// that have not been previously bound using Bind&lt;T&gt;
        /// </summary>
        /// <param name="view"></param>
        public void InjectView(IViewBase view)
        {
            var injections = new Injections(this, view.GetType());

            injections.Inject(view);
            Prepare(view);
        }
Exemple #2
0
        public virtual bool Bind <TInterface, TImpl>(TImpl impl, bool single = true)
            where TInterface : TBase
            where TImpl : TInterface
        {
            var ity = typeof(TInterface);

            if (single && _singles.ContainsKey(ity))
            {
                Warn($"Already have singleton value for {ity}");
                return(false);
            }

            var prep = new Injections(this, typeof(TImpl));
            var obj  = Prepare(prep.Inject(impl, ity, impl));

            if (single)
            {
                _singles[ity] = obj;
            }
            _injections[ity] = prep;

            return(true);
        }