コード例 #1
0
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(action => action.IsCrudAction())
         .Each(action => action.AddBefore(new CrudValidationBehaviorNode(action.InputType())));
 }
コード例 #2
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions().Each(a =>
     {
         a.ForAttributes<UrlRegistryCategoryAttribute>(att => a.ParentChain().UrlCategory.Category = att.Category);
     });
 }
コード例 #3
0
        public void Configure(BehaviorGraph graph)
        {
            var discoveredViewTokens = _facilities.SelectMany(x => x.FindViews(_types));
            var bag = new ViewBag(discoveredViewTokens);

            graph.Actions().Each(a => attachView(bag, a));
        }
コード例 #4
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions()
         .Where(x => x.Method.Name.StartsWith("Orchestrates") || x.Method.Name.StartsWith("Initiates"))
         .Where(x => x.InputType().GetProperties().Any(y => y.Name.Equals("CorrelationId")))
         .Each(x => x.WrapWith(typeof(SagaFindByIdBehavior<,>).MakeGenericType(x.HandlerType, x.HandlerType.GetProperty("State").PropertyType)));
 }
コード例 #5
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions()
         .Where(x => x.InputType().CanBeCastTo<JsonMessage>())
         .ToList()
         .Each(x => x.ParentChain().MakeAsymmetricJson());
 }
コード例 #6
0
        public void can_prepend_behaviors_in_front_of_an_action_4()
        {
            graph = BehaviorGraph.BuildFrom(x =>
            {
                x.Actions.IncludeTypesNamed(o => o.EndsWith("Controller"));

                x.Policies.AlterActions(a => a.WrapWith<MyWrapper>());
            });

            graph.Actions().Each(x => x.WrapWith(typeof(MyWrapper)));

            graph.Actions().Each(x =>
            {
                x.Previous.ShouldBeOfType<Wrapper>().BehaviorType.ShouldEqual(typeof(MyWrapper));
            });
        }
コード例 #7
0
        public void Configure(BehaviorGraph graph)
        {
            var views = _facilities.SelectMany(x => x.FindViews(_types));
            var bag = new ViewBag(views);

            graph.Actions().Each(a => AttemptToAttachViewToAction(bag, a, graph.Observer));
        }
コード例 #8
0
ファイル: ViewAttacher.cs プロジェクト: bbehrens/fubumvc
        public void Configure(BehaviorGraph graph)
        {
            IEnumerable<IViewToken> views = _facilities.SelectMany(x => x.FindViews(_types));
            var bag = new ViewBag(views);

            graph.Actions().Each(a => { attachView(bag, a); });
        }
コード例 #9
0
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(c => !c.HandlerType.Namespace.Contains("Login") && !c.HandlerType.Namespace.Contains("Home"))
         .Each(c => c.WrapWith<AuthenticationRequiredBehavior>());
 }
コード例 #10
0
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(action => action.IsCrudAction())
         .Each(action => action.AddBefore(new CrudErrorWrapperBehaviorNode()));
 }
コード例 #11
0
		public void Configure(BehaviorGraph graph)
		{
			graph
			.Actions()
			.Where(b => b.InputType() != null && b.InputType().Namespace.ToLower().Contains("sitemanagement"))
			.Each(chain => chain.WrapWith<NTCodingAuthenticationBehaviour>());
		}
コード例 #12
0
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(c => c.HasAttribute<SecureAttribute>())
         .Each(c => c.WrapWith<AuthenticationRequiredBehaviour>());
 }
コード例 #13
0
 public void Configure(BehaviorGraph graph)
 {
     //graph.Services.ServicesFor(typeof(IValidator<>).MakeGenericType(x.InputType()))
     graph.Actions()
         .Where(x => x.HasInput && ObjectFactory.Model.HasDefaultImplementationFor(typeof(IValidator<>).MakeGenericType(x.InputType())))
         .Each(x => x.AddBefore(new Wrapper(typeof(ValidationBehaviour<>).MakeGenericType(x.InputType()))));
 }
コード例 #14
0
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(action => action.InputType().IsAuthenticatedAPIRequest())
         .Each(action => action.ParentChain().Authorization.AddPolicy(new AuthenticationTokenAuthorizationPolicy()));
 }
コード例 #15
0
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(ShouldBePartial)
         .Select(x => x.ParentChain())
         .Each(x => x.IsPartialOnly = true);
 }
コード例 #16
0
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(ShouldBeCachedPartial)
         .Select(x => x.ParentChain())
         .Each(Modify);
 }
コード例 #17
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions().Where(x => x.OutputType().CanBeCastTo<FubuContinuation>()).Each(call =>
     {
         call.AddAfter(new ContinuationNode());
         graph.Observer.RecordCallStatus(call, "Adding ContinuationNode directly after action call");
     });
 }
コード例 #18
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions().Where(IsRedirectable).Each(call =>
     {
         call.AddAfter(new ContinuationNode());
         graph.Observer.RecordCallStatus(call, "Adding ContinuationNode directly after action call");
     });
 }
コード例 #19
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions()
         .Where(actionCall => actionCall.Method.Name.EndsWith("Command") &&
             actionCall.HasInput &
             actionCall.InputType().Name.EndsWith("InputModel"))
         .Each(actionCall => actionCall.AddBefore(new ValidationNode(actionCall.InputType())));
 }
コード例 #20
0
        public void SetUp()
        {
            graph = new DiagnosticsRegistry().BuildGraph();
            urls = MockRepository.GenerateMock<IUrlRegistry>();

            graph.Behaviors.Any().ShouldBeTrue();
            graph.Actions().Each(x => Debug.WriteLine(x.Description));
        }
コード例 #21
0
 public void Configure(BehaviorGraph graph)
 {
     // handle model binding errors when there is an input model
     graph
         .Actions()
         .Where(g => g.InputType() != null)
         .Each(g => g.AddBefore(new Wrapper(typeof (BindingErrorsHandler<>).MakeGenericType(g.InputType()))));
 }
コード例 #22
0
ファイル: ExamplePolicy.cs プロジェクト: bobpace/MvcToFubu
 public void Configure(BehaviorGraph graph)
 {
     var actions = graph.Actions().Where(x => x.HandlerType.Name.StartsWith("Example"));
     foreach (var action in actions)
     {
         action.AddBefore(new Wrapper(typeof(ExampleBehavior)));
     }
 }
コード例 #23
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions()
          .Where(action => action.HandlerType.HasAttribute<OnlyAllowRolesAttribute>() ||
                           action.Method.HasAttribute<OnlyAllowRolesAttribute>())
          .Each(action => action
              .ParentChain().Authorization
              .AddPolicy(typeof(AccessAuthorizationPolicy<>).MakeGenericType(action.HandlerType)));
 }
コード例 #24
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions().Where(x => x.IsAsync).Each(call =>
     {
         call.AddAfter(call.Method.ReturnType == typeof(Task)
                           ? new AsyncContinueWithNode()
                           : new AsyncContinueWithNode(call.OutputType()));
     });
 }
コード例 #25
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions()
          .Where(x => x.HasInput && x.InputType().Name.EndsWith("RoleModel"))
          .Each(x =>
          {
              var roleName = x.InputType().Name.Replace("RoleModel", string.Empty);
              x.ParentChain().Authorization.AddRole(roleName);
          });
 }
コード例 #26
0
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(action => !action.HandlerType.Namespace.StartsWith("FubuMVC.")) // Don't want this to apply to adv diagnostics!
         .Each(action => action
             .ParentChain()
             .Authorization
             .AddPolicy(typeof(AccessGroupAuthorizationPolicy<>).MakeGenericType(action.HandlerType)));
 }
コード例 #27
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions().Where(x => x.IsAsync).Each(call =>
     {
         call.AddAfter(call.Method.ReturnType == typeof (Task)
                           ? new AsyncContinueWithNode()
                           : new AsyncContinueWithNode(call.OutputType()));
         graph.Observer.RecordCallStatus(call, "Adding AsyncContinueWithNode directly after action call");
     });
 }
コード例 #28
0
        public void Configure(BehaviorGraph graph)
        {
            graph.Actions().Where(x => x.InputType().CanBeCastTo<JsonMessage>()).ToList().Each(x =>
            {
                var inputType = x.InputType();
                var deserialization = new DeserializeJsonNode(inputType);

                x.AddBefore(deserialization);
            });
        }
コード例 #29
0
 public void Configure(BehaviorGraph graph, IUrlRegistration registration)
 {
     graph.Actions().Each(action =>
     {
         ReflectionExtensions.ForAttribute<UrlForNewAttribute>((ICustomAttributeProvider) action.Method, att =>
         {
             registration.RegisterNew((ActionCall) action, att.Type);
         });
     });
 }
コード例 #30
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions().Each(a =>
     {
         // Sukant, it's just little bitty stuff like this.  If the Type in HandlerType is
         // decorated with the UrlRegistryCategoryAttribute, call through to the continuation
         // passed into the function
         a.HandlerType.ForAttribute<UrlRegistryCategoryAttribute>(att => a.ParentChain().UrlCategory.Category = att.Category);
         a.Method.ForAttribute<UrlRegistryCategoryAttribute>(att => a.ParentChain().UrlCategory.Category = att.Category);
     });
 }