Example #1
0
 public BehaviorGraphWriter(BehaviorGraph graph, IUrlRegistry urls, IServiceLocator services)
 {
     _graph = graph;
     _urls = urls;
     _services = services;
     _diagnosticsNamespace = GetType().Namespace;
 }
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Import<ApplyWindowsAuthentication>();

            theGraph = BehaviorGraph.BuildFrom(registry);
        }
 public void SetUp()
 {
     graph = new FubuRegistry(x =>
     {
         x.Actions.IncludeTypesNamed(o => o.EndsWith("Controller"));
     }).BuildGraph();
 }
 public void Configure(BehaviorGraph graph)
 {
     graph.Behaviors
         .Where(x => !x.IsPartialOnly)
         .Where(x => x.ResourceType().CanBeCastTo<JsonMessage>() || x.InputType().CanBeCastTo<JsonMessage>())
         .Each(x => x.MakeAsymmetricJson());
 }
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Import<ServerSentEventsExtension>();

            theGraph = BehaviorGraph.BuildFrom(registry);
        }
Example #6
0
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<JsonController>();

            theGraph = registry.BuildGraph();
        }
Example #7
0
 public PartialFactory(BehaviorGraph graph, IBehaviorFactory factory, ServiceArguments arguments, ICurrentChain currentChain)
 {
     _graph = graph;
     _factory = factory;
     _arguments = arguments;
     _currentChain = currentChain;
 }
 public void SetUp()
 {
     theGraph = BehaviorGraph.BuildFrom(x =>
     {
         x.Actions.IncludeClassesSuffixedWithController();
     });
 }
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<RouteAliasController>();

            theGraph = BehaviorGraph.BuildFrom(registry);
        }
Example #10
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Behaviors
         .Where(x => !x.IsPartialOnly)
         .Where(x => x.HasResourceType() && !x.HasOutput())
         .Each(x => x.ApplyConneg());
 }
        public void beforeAll()
        {
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<Controller1>();

            _graph = BehaviorGraph.BuildFrom(registry);
        }
        public void SetUp()
        {
            graph = new BehaviorGraph(null);
            matcher = new ActionSourceMatcher();

            pool = new TypePool();
        }
 public void Configure(BehaviorGraph graph)
 {
     graph.Behaviors
         .Where(x => x.ResourceType().CanBeCastTo<AjaxContinuation>())
         .ToList()
         .Each(Modify);
 }
 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 Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(c => c.HasAttribute<SecureAttribute>())
         .Each(c => c.WrapWith<AuthenticationRequiredBehaviour>());
 }
        public void Configure(BehaviorGraph graph)
        {
            var jobs = graph.Settings.Get<PollingJobSettings>().Jobs;

            jobs.Select(x => x.ToObjectDef())
                .Each(x => graph.Services.AddService(typeof(IPollingJob), x));
        }
        void IConfigurationAction.Configure(BehaviorGraph graph)
        {
            var chain = graph.BehaviorFor(_route);
            _nodes.Each(chain.AddToEnd);

            //graph.Observer.RecordStatus("Adding explicit route {0}".ToFormat(_route));
        }
Example #18
0
 public ExampleHtmlWriter(IServiceLocator serviceLocator, IUrlRegistry urlRegistry, BehaviorGraph behaviorGraph)
 {
     _serviceLocator = serviceLocator;
     _urlRegistry = urlRegistry;
     _behaviorGraph = behaviorGraph;
     _examplePageUrl = "_fubu/html/example".ToAbsoluteUrl();
 }
        public void SetUp()
        {
            graph = new FubuRegistry().BuildGraph();
            urls = MockRepository.GenerateMock<IUrlRegistry>();

            writer = new BehaviorGraphWriter(graph, urls, null);
        }
        public void Apply(BehaviorGraph graph, BehaviorChain chain)
        {
            // Don't override the route if it already exists
            if (chain.Route != null)
            {
                return;
            }

            // Don't override the route if the chain is a partial
            if (chain.IsPartialOnly)
            {
                return;
            }

            _observer = graph.Observer;

            ActionCall call = chain.Calls.FirstOrDefault();
            if (call == null) return;

            IUrlPolicy policy = _policies.FirstOrDefault(x => x.Matches(call, _observer)) ?? _defaultUrlPolicy;
            _observer.RecordCallStatus(call, "First matching UrlPolicy (or default): {0}".ToFormat(policy.GetType().Name));

            IRouteDefinition route = policy.Build(call);
            _constraintPolicy.Apply(call, route, _observer);

            _observer.RecordCallStatus(call, "Route definition determined by url policy: [{0}]".ToFormat(route.ToRoute().Url));
            chain.Route = route;
        }
        public void Configure(BehaviorGraph graph)
        {
            var jobs = graph.Settings.Get<ScheduledJobGraph>();
            var channels = graph.Settings.Get<ChannelGraph>();

            if (jobs.Jobs.Any(x => x.Channel == null) && jobs.DefaultChannel == null)
            {
                var missing = jobs.Jobs.Where(x => x.Channel == null);
                var message =
                    "No channel configured for jobs {0} and no default Scheduled job channel configured".ToFormat(
                        missing.Select(x => x.JobType.GetFullName()).Join(", "));

                throw new InvalidOperationException(message);
            }

            jobs.Jobs.Where(x => x.Channel == null).Each(x => x.Channel = jobs.DefaultChannel);

            jobs.Jobs.Each(job => {
                var accessor = job.Channel ?? jobs.DefaultChannel;
                var channel = channels.ChannelFor(accessor);
                if (channel == null)
                {
                    throw new InvalidOperationException("Nonexistent Channel '{0}' configured for Scheduled job {1}".ToFormat(accessor, job.JobType.GetFullName()));
                }

                channel.Rules.Add(job.ToRoutingRule());
            });
        }
 public void Configure(BehaviorGraph graph)
 {
     graph.FirstActions().Where(x => x.InputType().CanBeCastTo<DomainEntity>()).Each(call =>
     {
         call.WrapWith(typeof(EnsureEntityExistsBehavior<>), call.InputType());
     });
 }
Example #23
0
        private static IEnumerable<BehaviorChain> buildChains(BehaviorGraph graph)
        {
            var handlers = graph.Settings.Get<HandlerGraph>();

            // TODO -- move this to a HandlerSource after we fix the duplicate calls
            // across HandlerSource problem.
            handlers.Add(HandlerCall.For<SubscriptionsHandler>(x => x.Handle(new SubscriptionRequested())));
            handlers.Add(HandlerCall.For<SubscriptionsHandler>(x => x.Handle(new SubscriptionsChanged())));
            handlers.Add(HandlerCall.For<SubscriptionsHandler>(x => x.Handle(new SubscriptionsRemoved())));
            handlers.Add(HandlerCall.For<MonitoringControlHandler>(x => x.Handle(new TakeOwnershipRequest())));
            handlers.Add(HandlerCall.For<MonitoringControlHandler>(x => x.Handle(new TaskHealthRequest())));
            handlers.Add(HandlerCall.For<MonitoringControlHandler>(x => x.Handle(new TaskDeactivation())));

            handlers.ApplyGeneralizedHandlers();

            var policies = graph.Settings.Get<HandlerPolicies>();
            handlers.ApplyPolicies(policies.GlobalPolicies);

            foreach (var chain in handlers)
            {
                // Apply the error handling node
                chain.InsertFirst(new ExceptionHandlerNode(chain));

                // Hate how we're doing this, but disable tracing
                // on the polling job requests here.
                if (chain.InputType().Closes(typeof (JobRequest<>)))
                {
                    chain.Tags.Add(BehaviorChain.NoTracing);
                }
            }

            return handlers;
        }
        public void Configure(BehaviorGraph graph)
        {
            graph.Behaviors.Where(x => x.InputType().CanBeCastTo<ResourcePath>())
                .Each(x =>
                {
                    if (!x.Route.Pattern.Contains(ResourcePath.UrlSuffix))
                    {
                        x.Route.Append(ResourcePath.UrlSuffix);

                        x.Route.RegisterRouteCustomization(r =>
                        {
                            r.Defaults.Add("Part0", null);
                            r.Defaults.Add("Part1", null);
                            r.Defaults.Add("Part2", null);
                            r.Defaults.Add("Part3", null);
                            r.Defaults.Add("Part4", null);
                            r.Defaults.Add("Part5", null);
                            r.Defaults.Add("Part6", null);
                            r.Defaults.Add("Part7", null);
                            r.Defaults.Add("Part8", null);
                            r.Defaults.Add("Part9", null);
                        });
                    }

                });
        }
Example #25
0
        public static ConnegGraph Build(BehaviorGraph behaviorGraph)
        {
            var graph = new ConnegGraph();

            TypePool typePool = behaviorGraph.Types();
            var writers = typePool
                .TypesMatching(
                    x =>
                        x.Closes(typeof (IMediaWriter<>)) && x.IsConcreteWithDefaultCtor() &&
                        !x.IsOpenGeneric());

            graph.Writers.AddRange(writers);


            var readers = typePool
                .TypesMatching(
                    x =>
                        x.Closes(typeof (IReader<>)) && x.IsConcreteWithDefaultCtor() &&
                        !x.IsOpenGeneric());

            graph.Readers.AddRange(readers);


            return graph;
        }
		public void Configure(BehaviorGraph graph)
		{
			graph
			.Actions()
			.Where(b => b.InputType() != null && b.InputType().Namespace.ToLower().Contains("sitemanagement"))
			.Each(chain => chain.WrapWith<NTCodingAuthenticationBehaviour>());
		}
 public void Configure(BehaviorGraph graph)
 {
     graph
         .Actions()
         .Where(action => action.IsCrudAction())
         .Each(action => action.AddBefore(new CrudValidationBehaviorNode(action.InputType())));
 }
Example #28
0
        public void BuildBehaviors(TypePool pool, BehaviorGraph graph)
        {
            _graph = graph;

            pool.TypesMatching(TypeFilters.Matches).Each(scanMethods);
            _graph = null;
        }
 public void Configure(BehaviorGraph graph)
 {
     graph.Behaviors.Where(x => x.ResourceType() != null).Each(chain =>
     {
         chain.ResourceType().ForAttribute<CacheAttribute>(att => att.Alter(chain));
     });
 }
 public void Configure(BehaviorGraph graph)
 {
     graph.Actions()
         .Where(x => x.InputType().CanBeCastTo<JsonMessage>())
         .ToList()
         .Each(x => x.ParentChain().MakeAsymmetricJson());
 }