public void find_by_handler_type_if_only_one_method()
        {
            graph.Actions().Each(x => Debug.WriteLine(x.Description));

            urls.UrlFor <OnlyOneActionController>()
            .ShouldEqual("http://server/fubu/onlyoneaction/go");
        }
 public static ActionCall GetAction <T>(this BehaviorGraph graph)
 {
     if (graph.Actions().All(x => x.HandlerType != typeof(T)))
     {
         throw new Exception("Could not find handler of type {0} in behaviour graph with {1} actions."
                             .ToFormat(typeof(T).Name, graph.Actions().Count()));
     }
     return(graph.Actions().First(x => x.HandlerType == typeof(T)));
 }
Beispiel #3
0
        public void should_append_behavioral_node_to_void_end_point_attributed_calls()
        {
            var token   = new WebFormViewToken(typeof(FakeView));
            var actions = _graph.Actions().Where(x => !x.HasAnyOutputBehavior() &&
                                                 x.Method.HasAttribute <WebFormsEndpointAttribute>()).ToList();

            for (int index = 0; index < actions.Count; index++)
            {
                var call = actions[index];
                call.LastOrDefault().ShouldBeTheSameAs(token.ToBehavioralNode());
            }
        }
 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)));
 }
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(action => action.IsCrudAction())
         .Each(action => action.AddBefore(new CrudValidationBehaviorNode(action.InputType())));
 }
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions().Each(a =>
     {
         a.ForAttributes<UrlRegistryCategoryAttribute>(att => a.ParentChain().UrlCategory.Category = att.Category);
     });
 }
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions().Each(a =>
     {
         a.ForAttributes <UrlRegistryCategoryAttribute>(att => a.ParentChain().UrlCategory.Category = att.Category);
     });
 }
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(action => action.InputType().IsAuthenticatedAPIRequest())
         .Each(action => action.ParentChain().Authorization.AddPolicy(new AuthenticationTokenAuthorizationPolicy()));
 }
Beispiel #9
0
        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); });
        }
 public void Configure(BehaviorGraph graph)
 {
     graph
     .Actions()
     .Where(Handles)
     .Each(action => action.WrapWith <ActionExceptionWrapper <TServerErrorRequest> >());
 }
		public void Configure(BehaviorGraph graph)
		{
			graph
			.Actions()
			.Where(b => b.InputType() != null && b.InputType().Namespace.ToLower().Contains("sitemanagement"))
			.Each(chain => chain.WrapWith<NTCodingAuthenticationBehaviour>());
		}
Beispiel #12
0
 public void Configure(BehaviorGraph graph)
 {
     graph
     .Actions()
     .Where(action => action.InputType().IsAuthenticatedAPIRequest())
     .Each(action => action.ParentChain().Authorization.AddPolicy(new AuthenticationTokenAuthorizationPolicy()));
 }
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(c => c.HasAttribute<SecureAttribute>())
         .Each(c => c.WrapWith<AuthenticationRequiredBehaviour>());
 }
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions()
     .Where(x => x.InputType().CanBeCastTo <JsonMessage>())
     .ToList()
     .Each(x => x.ParentChain().MakeAsymmetricJson());
 }
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions()
         .Where(x => x.InputType().CanBeCastTo<JsonMessage>())
         .ToList()
         .Each(x => x.ParentChain().MakeAsymmetricJson());
 }
        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));
            });
        }
Beispiel #17
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));
        }
Beispiel #18
0
        public HtmlDocument Index()
        {
            var tags = new List <HtmlTag>();



            var groups = _graph
                         .Actions()
                         .Where(x => x.HandlerType.HasAttribute <FubuDiagnosticsAttribute>() && (!x.HasInput || x.HandlerType.GetAttribute <FubuDiagnosticsAttribute>().ShownInIndex) && x.Method.Name != "Index")
                         .GroupBy(x => x.HandlerType.GetAttribute <FubuDiagnosticsAttribute>().Description)
                         .OrderBy(x => x.Key);

            groups.Each(group =>
            {
                tags.Add(new HtmlTag("h3").Text(group.Key));
                var ul = new HtmlTag("ul");
                tags.Add(ul);


                group.Each <ActionCall>(action =>
                {
                    string text = action.Method.Name;
                    action.Method.ForAttribute <FubuDiagnosticsAttribute>(att => text = att.Description);

                    ul.Add("li/a").Text(text)
                    .Attr("href", action.ParentChain().RoutePattern);
                });
            });



            return(BuildDocument("Home", tags.ToArray()));
        }
Beispiel #19
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));
        }
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(action => action.IsCrudAction())
         .Each(action => action.AddBefore(new CrudErrorWrapperBehaviorNode()));
 }
        public void Configure(BehaviorGraph graph)
        {
            var navigationGraph = graph.Settings.Get <NavigationGraph>();

            graph.Actions().Each(
                action => action.ForAttributes <MenuItemAttribute>(att => Configure(action, att, navigationGraph)));
        }
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(c => !c.HandlerType.Namespace.Contains("Login") && !c.HandlerType.Namespace.Contains("Home"))
         .Each(c => c.WrapWith<AuthenticationRequiredBehavior>());
 }
        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));
            });
        }
 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()))));
 }
Beispiel #25
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");
     });
 }
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(ShouldBeCachedPartial)
         .Select(x => x.ParentChain())
         .Each(Modify);
 }
 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");
     });
 }
Beispiel #28
0
 public void Activate(IEnumerable <IPackageInfo> packages, IPackageLog log)
 {
     // Find the input models that have remote rules
     // "Bake" them into the remote graph
     _behaviorGraph
     .Actions()
     .Each(FillRules);
 }
 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()))));
 }
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(ShouldBePartial)
         .Select(x => x.ParentChain())
         .Each(x => x.IsPartialOnly = true);
 }
 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())));
 }
Beispiel #32
0
 public void Configure(BehaviorGraph graph)
 {
     graph
     .Actions()
     .Where(ShouldBePartial)
     .Select(x => x.ParentChain())
     .Each(x => x.IsPartialOnly = true);
 }
Beispiel #33
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");
     });
 }
 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");
     });
 }
Beispiel #35
0
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     // Find the input models that have remote rules
     // "Bake" them into the remote graph
     _behaviorGraph
     .Actions()
     .Each(FillRules);
 }
Beispiel #36
0
 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)));
     }
 }
 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())));
 }
 public void Configure(BehaviorGraph graph)
 {
     graph
     .Actions()
     .Where(ShouldBeCachedPartial)
     .Select(x => x.ParentChain())
     .Each(Modify);
 }
        public void SetUp()
        {
            graph = new DiagnosticsRegistry().BuildGraph();
            urls = MockRepository.GenerateMock<IUrlRegistry>();

            graph.Behaviors.Any().ShouldBeTrue();
            graph.Actions().Each(x => Debug.WriteLine(x.Description));
        }
Beispiel #40
0
        public void retrieve_a_url_by_action_negative_case()
        {
            graph.Actions().Each(x => Debug.WriteLine(x.Description));

            Exception <FubuException> .ShouldBeThrownBy(() =>
            {
                urls.UrlFor <OneController>(x => x.Ignored());
            });
        }
Beispiel #41
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()));
     });
 }
 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)));
 }
Beispiel #43
0
 public void Configure(BehaviorGraph behaviorGraph)
 {
     behaviorGraph.Actions()
     // Actions are frequently pulled from extendhealth bottles here i.e. .FromExtendHealthBottles().Each()...
     .Each(actionCall =>
     {
         Console.WriteLine("Error behavior added");
     });
 }
 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()));
     });
 }
 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)));
 }
        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);
            });
        }
        public void Configure(BehaviorGraph graph)
        {
            var settings = graph.Settings.Get <ValidationSettings>();
            var filter   = settings.As <IApplyValidationFilter>();

            graph
            .Actions()
            .Where(call => filter.Filter(call.ParentChain()))
            .Each(call => ApplyValidation(call, settings));
        }
 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);
     });
 }
Beispiel #49
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);
            });
        }
Beispiel #50
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions()
     .Where(x => x.HasOutput &&
            x.OutputType().GetProperties()
            .Any(p => p.Name.EndsWith("Settings")))
     .Each(x => x.AddAfter(new Wrapper(
                               typeof(OutputModelSettingBehavior <>)
                               .MakeGenericType(x.OutputType()))));
 }
 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");
     });
 }
 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");
     });
 }
 public void Configure(BehaviorGraph graph, IUrlRegistration registration)
 {
     graph.Actions().Each(action =>
     {
         ReflectionExtensions.ForAttribute<UrlForNewAttribute>((ICustomAttributeProvider) action.Method, att =>
         {
             registration.RegisterNew((ActionCall) action, att.Type);
         });
     });
 }
 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);
          });
 }
 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)));
 }
 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);
     });
 }
        public void Given()
        {
            var cut = new ActionCallMapper(new TypeDescriptorCache());

            var graph = new BehaviorGraph();
            var chain = graph.AddActionFor("api/group1/{input}", typeof(Action1));

            chain.Route.AddHttpMethodConstraint("POST");
            var action = graph.Actions().First();

            _result = cut.GetSwaggerOperations(action).First();
        }
        public void Configure(BehaviorGraph graph)
        {
            graph.Actions()
            .Where(_filters.Matches)
            .Each(call =>
            {
                var matchingFilter = _filters.GetDescriptionOfFirstMatchingInclude(call);

                call.Trace("{0} [matched on filter '{1}']".ToFormat(_reasonForModification, matchingFilter));

                _modification(call);
            });
        }
Beispiel #59
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions()
     .Where(x => !x.HasAnyOutputBehavior())
     .Each(x => x.Method.ForAttribute <WebFormsEndpointAttribute>(att =>
     {
         var token = new WebFormViewToken(att.ViewType);
         x.AddToEnd(token.ToBehavioralNode());
         graph.Observer.RecordCallStatus(x,
                                         "Action '{0}' has {1} declared, using WebForms view '{2}'".ToFormat(
                                             x.Description, typeof(WebFormsEndpointAttribute).Name, token));
     }));
 }
        public void Configure(BehaviorGraph graph)
        {
            graph.Behaviors
            .Where(action => action.InputType().IsAPIRequest())
            .Each(action => action.MakeAsymmetricJson());

            graph
            .Actions()
            .Where(action => action.InputType().IsAuthenticatedAPIRequest())
            .Each(action =>
                  action.ParentChain().Authorization.AddPolicy(typeof(AuthenticationTokenAuthorizationPolicy))
                  );
        }