private void TryToApplyDecorator(ExpressionBuiltEventArgs e) { if (this.MustDecorate(e.RegisteredServiceType, out Type? closedDecoratorType)) { var decoratorInterceptor = new ServiceDecoratorExpressionInterceptor(this.data, this.registrationsCache, e); if (decoratorInterceptor.SatisfiesPredicate()) { if (this.data.DecoratorTypeFactory != null) { // Context gets set by SatisfiesPredicate var context = decoratorInterceptor.Context !; closedDecoratorType = this.GetDecoratorTypeFromDecoratorFactory( e.RegisteredServiceType, context); } if (closedDecoratorType != null) { decoratorInterceptor.ApplyDecorator(closedDecoratorType); } } } }
private void TryToApplyDecorator(ExpressionBuiltEventArgs e) { Type closedDecoratorType; if (this.MustDecorate(e.RegisteredServiceType, out closedDecoratorType)) { var decoratorInterceptor = new ServiceDecoratorExpressionInterceptor(this.data, this.registrationsCache, e); if (decoratorInterceptor.SatisfiesPredicate()) { if (this.data.DecoratorTypeFactory != null) { closedDecoratorType = this.GetDecoratorTypeFromDecoratorFactory( e.RegisteredServiceType, decoratorInterceptor.Context); } if (closedDecoratorType != null) { decoratorInterceptor.ApplyDecorator(closedDecoratorType); } } } }