public virtual ConstraintDsl <TDsl> ExceptFor <TController>() where TController : Controller { var controllerTypeConstraint = new ControllerTypeConstraint <TController>(); AddRegistration(new ExceptInstanceRegistration(controllerTypeConstraint, EmptyActionDescriptor.Instance, EmptyControllerDescriptor.Instance, FilterScope.Controller)); return(this); }
private static IConstraint CreateActionConstraint <TController>(ActionDescriptor actionDescriptor) { var controllerTypeConstraint = new ControllerTypeConstraint <TController>(); var actionConstraint = new ControllerActionConstraint(actionDescriptor); var contContraint = new AndConstraint(controllerTypeConstraint, actionConstraint); return(contContraint); }
public virtual ConstraintDsl <TDsl> ExceptFor <TController>(Expression <Func <TController, object> > func) where TController : Controller { var actionDescriptor = func.CreateActionDescriptor(); var controllerTypeConstraint = new ControllerTypeConstraint <TController>(); var actionConstraint = new ControllerActionConstraint(actionDescriptor); var contContraint = new AndConstraint(controllerTypeConstraint, actionConstraint); AddRegistration(CreateInstanceRegistration(new NotConstraint(contContraint), actionDescriptor, actionDescriptor.ControllerDescriptor, FilterScope.Action)); return(this); }
public void can_match_inhertied_controller() { Expression <Func <InheritedTestController, object> > func = c => c.ReturnNull(); var controllerTypeConstraint = new ControllerTypeConstraint <TestController>(); var actionDescriptor = func.CreateActionDescriptor(); controllerTypeConstraint .IsSatisfiedBy(new ControllerFilterSelector(null, actionDescriptor.ControllerDescriptor, EmptyActionDescriptor.Instance)) .ShouldBeTrue(); }
public void can_match_inhertied_controller() { Expression<Func<InheritedTestController, object>> func = c => c.ReturnNull(); var controllerTypeConstraint = new ControllerTypeConstraint<TestController>(); var actionDescriptor = func.CreateActionDescriptor(); controllerTypeConstraint .IsSatisfiedBy(new ControllerFilterSelector(null, actionDescriptor.ControllerDescriptor, EmptyActionDescriptor.Instance)) .ShouldBeTrue(); }
public void can_match_castle_proxied_controller() { var controllerTypeConstraint = new ControllerTypeConstraint <TestController>(); var proxyGenerator = new ProxyGenerator(); var interfaceProxyWithTarget = proxyGenerator.CreateClassProxy <TestController>(); var controllerType = interfaceProxyWithTarget.GetType(); var actionDescriptor = new ReflectedActionDescriptor(controllerType.GetMethod("ReturnViewResult"), "ReturnViewResult", new ReflectedControllerDescriptor(controllerType)); controllerTypeConstraint .IsSatisfiedBy(new ControllerFilterSelector(null, actionDescriptor.ControllerDescriptor, EmptyActionDescriptor.Instance)) .ShouldBeTrue(); }
public void can_match_castle_proxied_controller() { var controllerTypeConstraint = new ControllerTypeConstraint<TestController>(); var proxyGenerator = new ProxyGenerator(); var interfaceProxyWithTarget = proxyGenerator.CreateClassProxy<TestController>(); var controllerType = interfaceProxyWithTarget.GetType(); var actionDescriptor = new ReflectedActionDescriptor(controllerType.GetMethod("ReturnViewResult"), "ReturnViewResult", new ReflectedControllerDescriptor(controllerType)); controllerTypeConstraint .IsSatisfiedBy(new ControllerFilterSelector(null, actionDescriptor.ControllerDescriptor, EmptyActionDescriptor.Instance)) .ShouldBeTrue(); }
public void can_resolve_through_registry() { var controllerTypeConstraint = new ControllerTypeConstraint<TestController>(); var method = typeof(TestController).GetMethods().First(x => x.Name.Equals("ReturnNull") && x.GetParameters().Count() == 0); var actionDescriptor = new ReflectedActionDescriptor(method, "ReturnNull", new ReflectedControllerDescriptor(typeof(TestController))); var registry = new ActionFilterRegistry(new FluentMvcObjectFactory()); registry.Add(new ControllerActionRegistryItem(typeof(TestFilter), controllerTypeConstraint, actionDescriptor, actionDescriptor.ControllerDescriptor)); var proxyGenerator = new ProxyGenerator(); var interfaceProxyWithTarget = proxyGenerator.CreateClassProxy<TestController>(); var controllerType = interfaceProxyWithTarget.GetType(); var methodInfos = controllerType.GetMethods(); var proxyActionDescriptor = new ReflectedActionDescriptor(methodInfos.First(x => x.Name.Equals("ReturnNull") && x.GetParameters().Count() == 0), "ReturnNull", new ReflectedControllerDescriptor(controllerType)); registry .CanSatisfy(new ControllerActionFilterSelector(null, proxyActionDescriptor, proxyActionDescriptor.ControllerDescriptor)) .ShouldBeTrue(); }
public void can_resolve_through_registry() { var controllerTypeConstraint = new ControllerTypeConstraint <TestController>(); var method = typeof(TestController).GetMethods().First(x => x.Name.Equals("ReturnNull") && x.GetParameters().Count() == 0); var actionDescriptor = new ReflectedActionDescriptor(method, "ReturnNull", new ReflectedControllerDescriptor(typeof(TestController))); var registry = new ActionFilterRegistry(new FluentMvcObjectFactory()); registry.Add(new ControllerActionRegistryItem(typeof(TestFilter), controllerTypeConstraint, actionDescriptor, actionDescriptor.ControllerDescriptor)); var proxyGenerator = new ProxyGenerator(); var interfaceProxyWithTarget = proxyGenerator.CreateClassProxy <TestController>(); var controllerType = interfaceProxyWithTarget.GetType(); var methodInfos = controllerType.GetMethods(); var proxyActionDescriptor = new ReflectedActionDescriptor(methodInfos.First(x => x.Name.Equals("ReturnNull") && x.GetParameters().Count() == 0), "ReturnNull", new ReflectedControllerDescriptor(controllerType)); registry .CanSatisfy(new ControllerActionFilterSelector(null, proxyActionDescriptor, proxyActionDescriptor.ControllerDescriptor)) .ShouldBeTrue(); }