/// <summary> /// /// </summary> /// <param name="context"></param> protected override void Action(IConventionalContext context) { var action = context.Services.GetSingletonInstanceOrNull <IProxyConventionalAction>(); if (action == null) { return; } var typeList = context.GetOrDefault(Interceptors, default(ITypeList <IInterceptor>)); var ctx = new ProxyConventionalActionContext(context.Services, context.Types.Where(t => t.IsStandardType()), context.TypePredicate, typeList); action.Action(ctx); }
public void Action() { var action = new ProxyConventionalAction(); var services = new ServiceCollection(); var types = new List <Type> { typeof(TestProxiedService) }; var interceptor = new TypeList <IInterceptor>(); Expression <Func <Type, bool> > typePredicate = t => true; interceptor.Add <TestInterceptor>(); var context = new ProxyConventionalActionContext(services, types, typePredicate, interceptor); Should.NotThrow(() => action.Action(context)); services.GetSingletonInstance <ServiceInterceptorList>().GetInterceptors(typeof(TestProxiedService)).ShouldHaveSingleItem().ShouldBe(typeof(TestInterceptor)); }
public void Action() { var action = new ProxyConventionalAction(); var services = new ServiceCollection(); var types = new List <Type> { typeof(TestProxiedService) }; var interceptor = new TypeList <IInterceptor>(); Expression <Func <Type, bool> > typePredicate = t => true; interceptor.Add <TestInterceptor>(); var context = new ProxyConventionalActionContext(services, types, typePredicate, interceptor); Should.NotThrow(() => action.Action(context)); services.ShouldContainTransient(typeof(TestInterceptor)); services.ShouldContainSingleton(typeof(IAspectConfiguration), typeof(AspectConfiguration)) .ImplementationInstance .ShouldBeOfType <AspectConfiguration>() .Interceptors.ShouldHaveSingleItem(); }