private InstanceProducer ApplyDecorator(InjectionTargetInfo target, Expression expression, List <PredicatePair> predicatePairs) { var visitor = new ContextualDecoratorExpressionVisitor(target, predicatePairs); expression = visitor.Visit(expression); if (!visitor.AllContextualDecoratorsApplied) { throw new InvalidOperationException("Couldn't apply the contextual decorator " + visitor.UnappliedDecorators.Last().ToFriendlyName() + ". Make sure that all " + "registered decorators that wrap this decorator are transient and don't depend on " + "Func<" + target.TargetType.ToFriendlyName() + ">."); } return(InstanceProducer.FromExpression(target.TargetType, expression, this.container)); }
public Expression BuildParameterExpression(ParameterInfo parameter) { var expression = this.defaultBehavior.BuildParameterExpression(parameter); List <PredicatePair> predicatePairs; if (this.MustApplyContextualDecorator(parameter.ParameterType, out predicatePairs)) { var visitor = new ContextualDecoratorExpressionVisitor(parameter, predicatePairs); expression = visitor.Visit(expression); if (!visitor.AllContextualDecoratorsApplied) { throw new InvalidOperationException("Couldn't apply the contextual decorator " + visitor.UnappliedDecorators.Last().FullName + ". Make sure that all registered " + "decorators that wrap this decorator are transient and don't depend on " + "Func<" + parameter.ParameterType.FullName + ">."); } } return(expression); }
public Expression BuildExpression(InjectionConsumerInfo consumer) { var expression = this.defaultBehavior.BuildExpression(consumer); List<PredicatePair> predicatePairs; if (this.MustApplyContextualDecorator(consumer.Target.TargetType, out predicatePairs)) { var visitor = new ContextualDecoratorExpressionVisitor(consumer.Target, predicatePairs); expression = visitor.Visit(expression); if (!visitor.AllContextualDecoratorsApplied) { throw new InvalidOperationException("Couldn't apply the contextual decorator " + visitor.UnappliedDecorators.Last().FullName + ". Make sure that all registered " + "decorators that wrap this decorator are transient and don't depend on " + "Func<" + consumer.Target.TargetType.FullName + ">."); } } return expression; }