예제 #1
0
        private Func <IDependencyResolver, T> GetComponentFactory <T>()
        {
            Func <IDependencyResolver, object> factory;

            if (_registrations.TryGetValue(typeof(T), out factory))
            {
                return(resolver => (T)(factory(resolver)));
            }
            else if (_parent != null)
            {
                return(_parent.GetComponentFactory <T>());
            }
            else
            {
                return(null);
            }
        }
        public Func <IDependencyResolver, T> GetComponentFactory <T>()
        {
            Func <IDependencyResolver, object> factory;

            if (_registrations.TryGetValue(typeof(T), out factory))
            {
                return(resolver => (T)(factory(resolver)));
            }
            else if (_parent != null)
            {
                return(_parent.GetComponentFactory <T>());
            }
            else
            {
                throw new InvalidOperationException(string.Format("The requested component of type {0} was not registered.", typeof(T)));
            }
        }