private void RegisterDecoratorCore(Type serviceType, Type decoratorType, Predicate <DecoratorPredicateContext> predicate = null, Lifestyle lifestyle = null) { Requires.IsNotNull(serviceType, nameof(serviceType)); Requires.IsNotNull(decoratorType, nameof(decoratorType)); Requires.ServiceTypeIsNotClosedWhenImplementationIsOpen(serviceType, decoratorType); Requires.ServiceOrItsGenericTypeDefinitionIsAssignableFromImplementation(serviceType, decoratorType, nameof(serviceType)); Requires.ImplementationHasSelectableConstructor(this, decoratorType, nameof(decoratorType)); Requires.IsDecorator(this, serviceType, decoratorType, nameof(decoratorType)); Requires.DecoratorIsNotAnOpenGenericTypeDefinitionWhenTheServiceTypeIsNot(serviceType, decoratorType, nameof(decoratorType)); Requires.OpenGenericTypeDoesNotContainUnresolvableTypeArguments(serviceType, decoratorType, nameof(decoratorType)); var interceptor = new DecoratorInterceptor( new DecoratorExpressionInterceptorData( this, serviceType, decoratorType, predicate, lifestyle ?? this.SelectionBasedLifestyle)); this.ExpressionBuilt += interceptor.ExpressionBuilt; }
public void role_is_decorator() { var interceptor = new DecoratorInterceptor(typeof(IWidget), typeof(WidgetDecorator)); interceptor.Role.ShouldBe(InterceptorRole.Decorates); }
public void accepts_type_is_the_plugin_type() { var interceptor = new DecoratorInterceptor(typeof(IWidget), typeof(WidgetDecorator)); interceptor.Accepts.ShouldBe(typeof(IWidget)); }