Ejemplo n.º 1
0
        /// <summary>
        /// 构建信息
        /// </summary>
        /// <param name="rules">服务类型规则</param>
        /// <param name="scope"></param>
        /// <param name="context">构建行为在执行过程的上下文</param>
        /// <returns></returns>
        public object[] ResolveAll(RegisterRule[] rules, ILifetimeScope scope, IResolveContext context)
        {
            var list = new List <object>(rules.Length);

            foreach (var rule in rules)
            {
                list.Add(RegisterRuleBuilder.Build(rule, this, this).Invoke(rule, this, scope, context));
            }

            return(list.ToArray());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 构建信息
        /// </summary>
        /// <param name="rule">服务类型规则</param>
        /// <param name="scope">scope</param>
        /// <param name="context">构建行为在执行过程的上下文</param>
        /// <returns></returns>
        public object ResolveRule(RegisterRule rule, ILifetimeScope scope, IResolveContext context)
        {
            if (rule.CanNotResolve != null)
            {
                throw new Exception(string.Format("can not resolve the {0}", rule.ServiceType.FullName), rule.CanNotResolve);
            }

            try
            {
                return(RegisterRuleBuilder.Build(rule, this, this).Invoke(rule, this, scope, context));
            }
            catch (Exception ex)
            {
                rule.CanNotResolve = ex;
                throw new Exception(string.Format("can not resolve the {0}", rule.ServiceType.FullName), rule.CanNotResolve);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 构建信息
        /// </summary>
        /// <param name="rule">服务类型规则</param>
        /// <param name="scope">scope</param>
        /// <param name="context">构建行为在执行过程的上下文</param>
        /// <returns></returns>
        public object ResolveRule(RegisterRule rule, ILifetimeScope scope, IResolveContext context)
        {
            if (rule.CanNotResolve != null)
            {
                throw new Exception(string.Format("can not resolve the {0}", rule.ServiceType.FullName), rule.CanNotResolve);
            }

            try
            {
                return(RegisterRuleBuilder.Build(rule, this, this).Invoke(rule, this, scope, context));
            }
            catch (Exception ex)
            {
                var inner = ex.GetInnerException();
                rule.CanNotResolve = new Exception(inner.Message)
                {
                    Source = inner.Source, HelpLink = inner.HelpLink
                };
                throw new Exception(string.Format("can not resolve the {0}", rule.ServiceType.FullName), rule.CanNotResolve);
            }
        }