public bool TryResolve(Type key, out object val)
        {
            Contract.Requires((object)key != null);

            Lifetime.LifetimeBase life = null;

            if (this.TryGetAssociation(key, out life))
            {
                Debug.Assert(life != null);
                if (life.TryGetInstance(_resolver, out val))
                {
                    return(true);
                }
            }

            val = null;
            return(false);
        }
Esempio n. 2
0
        public bool TryResolve(TAssocKey key, out object val)
        {
            TurboContract.Requires(key != null, conditionString: "key != null");

            Lifetime.LifetimeBase life = null;

            if (_association.TryGetAssociation(key, out life))
            {
                TurboContract.Assert(life != null, conditionString: "life != null");
                if (life.TryGetInstance(_resolver, out val))
                {
                    return(true);
                }
            }

            val = null;
            return(false);
        }
        public bool TryResolve <T>(out T val)
        {
            Lifetime.LifetimeBase life = null;

            if (this.TryGetAssociation(typeof(T), out life))
            {
                TurboContract.Assert(life != null, conditionString: "life != null");
                if (life.TryGetInstance(_resolver, out object tmp))
                {
                    if (tmp is T)
                    {
                        val = (T)tmp;
                        return(true);
                    }
                }
            }

            val = default(T);
            return(false);
        }
        public bool TryResolve <T>(out T val)
        {
            Lifetime.LifetimeBase life = null;

            if (this.TryGetAssociation(typeof(T), out life))
            {
                Debug.Assert(life != null);
                object tmp = null;
                if (life.TryGetInstance(_resolver, out tmp))
                {
                    if (tmp is T)
                    {
                        val = (T)tmp;
                        return(true);
                    }
                }
            }

            val = default(T);
            return(false);
        }