示例#1
0
        public void register_with_basic_authentication_disabled()
        {
            var registry = new FubuRegistry();

            registry.AlterSettings <AuthenticationSettings>(_ =>
            {
                _.Enabled       = true;
                _.Saml2.Enabled = true;
            });

            var samlCertificateRepository = MockRepository.GenerateMock <ISamlCertificateRepository>();

            samlCertificateRepository.Stub(x => x.AllKnownCertificates()).Return(new SamlCertificate[0]);
            registry.Services.SetServiceIfNone <ISamlCertificateRepository>(samlCertificateRepository);

            registry.Services.SetServiceIfNone <IPrincipalBuilder>(MockRepository.GenerateMock <IPrincipalBuilder>());
            registry.Services.AddService <ISamlResponseHandler>(MockRepository.GenerateMock <ISamlResponseHandler>());



            registry.AlterSettings <AuthenticationSettings>(x => {
                x.MembershipEnabled = MembershipStatus.Disabled;
            });

            using (var runtime = registry.ToRuntime())
            {
                var container = runtime.Get <IContainer>();

                var strategies = container.GetAllInstances <IAuthenticationStrategy>();
                strategies.Single().ShouldBeOfType <SamlAuthenticationStrategy>();
            }
        }
示例#2
0
        public void Configure(FubuRegistry registry)
        {
            MimeType.New("text/jsx", ".jsx");

            registry.Services <DiagnosticServiceRegistry>();

            registry.AlterSettings <AssetSettings>(x => x.AllowableExtensions.Add(".jsx"));

            registry.AlterSettings <DiagnosticsSettings>(x =>
            {
                x.TraceLevel = TraceLevel.Verbose;
            });

            registry.Configure(graph => {
                var settings = graph.Settings.Get <DiagnosticsSettings>();

                if (settings.TraceLevel == TraceLevel.Verbose)
                {
                    graph.Services.Clear(typeof(IBindingLogger));
                    graph.Services.AddService <IBindingLogger, RecordingBindingLogger>();

                    graph.Services.Clear(typeof(IBindingHistory));
                    graph.Services.AddService <IBindingHistory, BindingHistory>();

                    graph.Services.AddService <ILogListener, RequestTraceListener>();
                }

                if (settings.TraceLevel == TraceLevel.Production)
                {
                    graph.Services.AddService <ILogListener, ProductionModeTraceListener>();
                }
            });
        }
示例#3
0
        public static BehaviorGraph Build(FubuRegistry registry, IPerfTimer perfTimer,
                                          IEnumerable <Assembly> packageAssemblies, IActivationDiagnostics diagnostics, IFubuApplicationFiles files)
        {
            var featureLoader = new FeatureLoader();

            featureLoader.LookForFeatures();

            if (registry.Mode.InDevelopment())
            {
                registry.AlterSettings <DiagnosticsSettings>(_ => _.TraceLevel = TraceLevel.Verbose);
                registry.AlterSettings <AssetSettings>(_ => _.SetupForDevelopment());
            }



            var graph = new BehaviorGraph
            {
                ApplicationAssembly = registry.ApplicationAssembly,
                PackageAssemblies   = packageAssemblies
            };

            var accessorRules         = AccessorRulesCompiler.Compile(graph, perfTimer);
            var validationCompilation = ValidationCompiler.Compile(graph, perfTimer, registry);



            var config = registry.Config;

            perfTimer.Record("Applying Settings", () => applySettings(config, graph, diagnostics, files));

            perfTimer.Record("Enable built in polling jobs", () => enableBuiltInJobs(graph));
            perfTimer.Record("Applying Feature Settings", () => featureLoader.ApplyAll(graph.Settings, registry).Wait(30.Seconds()).AssertFinished());


            config.Add(new ActionlessViewChainSource());
            perfTimer.Record("Local Application BehaviorGraph", () => config.BuildLocal(graph, perfTimer));

            perfTimer.Record("Explicit Configuration", () => config.Global.Explicits.RunActions(graph));
            perfTimer.Record("Global Policies", () => config.Global.Policies.RunActions(graph));

            perfTimer.Record("Inserting Conneg and Authorization Nodes",
                             () => insertConnegAndAuthorizationNodes(graph));

            perfTimer.Record("Applying Global Reorderings", () => config.ApplyGlobalReorderings(graph));


            if (registry.Mode.InDevelopment() || graph.Settings.Get <DiagnosticsSettings>().TraceLevel != TraceLevel.None)
            {
                perfTimer.Record("Applying Tracing", () => ApplyTracing.Configure(graph));
            }


            Task.WaitAll(new Task[] { accessorRules, validationCompilation }, 30.Seconds()).AssertFinished();

            new AutoImportModelNamespacesConvention().Configure(graph);

            return(graph);
        }
示例#4
0
 public HealthMonitoringExpression ScheduledExecution(ScheduledExecution scheduledExecution)
 {
     _parent.AlterSettings <PollingJobSettings>(x =>
     {
         x.AddJob <HealthMonitorPollingJob, HealthMonitoringSettings>(settings => settings.Interval)
         .ScheduledExecution = scheduledExecution;
     });
     return(this);
 }
示例#5
0
        public void Configure(FubuRegistry registry)
        {
            registry.AlterSettings <ViewEngineSettings>(x => x.AddFacility(this));
            registry.Services(registerServices);

            registry.AlterSettings <CommonViewNamespaces>(addNamespacesForViews);

            registry.AlterSettings <AssetSettings>(registerWatchSettings);
        }
        public void include_explicitly()
        {
            registry.AlterSettings <ConfigurationSettings>(x => {
                x.Include <FooSettings>();
            });

            TheResultingSettings.Name.ShouldEqual("Max");
            TheResultingSettings.Age.ShouldEqual(9);
        }
        public static BehaviorGraph Build(FubuRegistry registry, IPerfTimer perfTimer,
            IEnumerable<Assembly> packageAssemblies, IActivationDiagnostics diagnostics, IFubuApplicationFiles files)
        {
            var featureLoader = new FeatureLoader();
            featureLoader.LookForFeatures();

            if (registry.Mode.InDevelopment())
            {
                registry.AlterSettings<DiagnosticsSettings>(_ => _.TraceLevel = TraceLevel.Verbose);
                registry.AlterSettings<AssetSettings>(_ => _.SetupForDevelopment());
            }

            
            

            var graph = new BehaviorGraph
            {
                ApplicationAssembly = registry.ApplicationAssembly,
                PackageAssemblies = packageAssemblies
            };

            var accessorRules = AccessorRulesCompiler.Compile(graph, perfTimer);



            var config = registry.Config;

            perfTimer.Record("Applying Settings", () => applySettings(config, graph, diagnostics, files));

            perfTimer.Record("Enable built in polling jobs", () => enableBuiltInJobs(graph));
            perfTimer.Record("Applying Feature Settings", () => featureLoader.ApplyAll(graph.Settings, registry).Wait());

            perfTimer.Record("Local Application BehaviorGraph", () => config.BuildLocal(graph, perfTimer));

            perfTimer.Record("Explicit Configuration", () => config.Global.Explicits.RunActions(graph));
            perfTimer.Record("Global Policies", () => config.Global.Policies.RunActions(graph));

            perfTimer.Record("Inserting Conneg and Authorization Nodes",
                () => insertConnegAndAuthorizationNodes(graph));

            perfTimer.Record("Applying Global Reorderings", () => config.ApplyGlobalReorderings(graph));


            if (registry.Mode.InDevelopment() || graph.Settings.Get<DiagnosticsSettings>().TraceLevel != TraceLevel.None)
            {
                perfTimer.Record("Applying Tracing", () => ApplyTracing.Configure(graph));
            }

            accessorRules.Wait();

            new AutoImportModelNamespacesConvention().Configure(graph);

            return graph;
        }
        public void should_start_when_transport_disabled()
        {
            var registry = new FubuRegistry();

            registry.AlterSettings <TransportSettings>(x =>
            {
                x.Enabled           = true;
                x.InMemoryTransport = InMemoryTransportMode.Enabled;
            });
            registry.AlterSettings <LightningQueueSettings>(x => x.DisableIfNoChannels = true);
            using (var application = registry.ToRuntime())
            {
            }
        }
示例#9
0
        public void do_nothing_if_tracing_is_off()
        {
            var registry = new FubuRegistry();

            registry.AlterSettings <DiagnosticsSettings>(x => x.TraceLevel = TraceLevel.None);
            registry.Configure(graph =>
            {
                chain1 = new RoutedChain("something");
                chain1.AddToEnd(Wrapper.For <SimpleBehavior>());
                chain1.AddToEnd(Wrapper.For <DifferentBehavior>());
                graph.AddChain(chain1);

                chain2 = new BehaviorChain();
                chain2.IsPartialOnly = true;
                chain2.AddToEnd(Wrapper.For <SimpleBehavior>());
                chain2.AddToEnd(Wrapper.For <DifferentBehavior>());
                graph.AddChain(chain2);
            });



            var notTracedGraph = BehaviorGraph.BuildFrom(registry);

            notTracedGraph.Behaviors.SelectMany(x => x).Any(x => x is DiagnosticBehavior).ShouldBeFalse();
            notTracedGraph.Behaviors.SelectMany(x => x).Any(x => x is BehaviorTracer).ShouldBeFalse();
        }
        public void register_with_basic_authentication_disabled()
        {
            var registry = new FubuRegistry();

            registry.Import <Saml2Extensions>();
            registry.Import <ApplyAuthentication>();

            var samlCertificateRepository = MockRepository.GenerateMock <ISamlCertificateRepository>();

            samlCertificateRepository.Stub(x => x.AllKnownCertificates()).Return(new SamlCertificate[0]);

            registry.Services(x =>
            {
                x.SetServiceIfNone <IPrincipalBuilder>(MockRepository.GenerateMock <IPrincipalBuilder>());
                x.AddService <ISamlResponseHandler>(MockRepository.GenerateMock <ISamlResponseHandler>());
                x.SetServiceIfNone <ISamlCertificateRepository>(samlCertificateRepository);
            });

            registry.AlterSettings <AuthenticationSettings>(x => {
                x.MembershipEnabled = MembershipStatus.Disabled;
            });

            var container = new Container();
            var runtime   = FubuApplication.For(registry).StructureMap(container).Bootstrap();


            var strategies = container.GetAllInstances <IAuthenticationStrategy>();

            strategies.Single().ShouldBeOfType <SamlAuthenticationStrategy>();
        }
        public void get_error_messages_in_production_mode()
        {
            var registry = new FubuRegistry();

            registry.ServiceBus.Enable(true);
            registry.Features.Diagnostics.Enable(TraceLevel.Production);
            registry.ServiceBus.EnableInMemoryTransport();
            registry.AlterSettings <LightningQueueSettings>(x => x.DisableIfNoChannels = true);

            using (var runtime = registry.ToRuntime())
            {
                var bus = runtime.Get <IServiceBus>();

                bus.Consume(new TracedInput {
                    Fail = true
                });


                var history = runtime.Get <IChainExecutionHistory>();

                var log = history.RecentReports().Single(x => x.RootChain != null && x.RootChain.InputType() == typeof(TracedInput));

                log.Steps.Any(x => x.Log is ExceptionReport).ShouldBeTrue();
                log.HadException.ShouldBeTrue();
            }
        }
示例#12
0
        public void default_namespaces_are_set_including_anything_from_CommonViewNamespaces()
        {
            var registry = new FubuRegistry();

            registry.Import <RazorViewFacility>();
            registry.AlterSettings <CommonViewNamespaces>(x =>
            {
                x.Add("Foo");
                x.Add("Bar");
            });

            var graph         = BehaviorGraph.BuildFrom(registry);
            var useNamespaces = graph.Services.DefaultServiceFor <CommonViewNamespaces>().Value.As <CommonViewNamespaces>();

            useNamespaces.Namespaces.ShouldHaveTheSameElementsAs(new[]
            {
                "System.Web",
                "System",
                "FubuCore",
                "System.Linq",
                "HtmlTags",
                "FubuMVC.Core.UI",
                "FubuMVC.Core.UI.Extensions",
                "FubuMVC.Razor",
                "Foo",
                "Bar"
            });
        }
        public void is_registered()
        {
            var registry = new FubuRegistry();

            registry.AlterSettings <CommonViewNamespaces>(x =>
            {
                x.Add("Foo");
                x.Add("Bar");
            });

            using (var runtime = registry.ToRuntime())
            {
                var container = runtime.Get <IContainer>();

                var useNamespaces = container.GetInstance <CommonViewNamespaces>();

                useNamespaces.Namespaces.ShouldContain(typeof(VirtualPathUtility).Namespace);
                useNamespaces.Namespaces.ShouldContain(typeof(string).Namespace);
                useNamespaces.Namespaces.ShouldContain(typeof(FileSet).Namespace);
                useNamespaces.Namespaces.ShouldContain(typeof(ParallelQuery).Namespace);
                useNamespaces.Namespaces.ShouldContain(typeof(HtmlTag).Namespace);
                useNamespaces.Namespaces.ShouldContain("FubuMVC.Tests.Http.Hosting");
                useNamespaces.Namespaces.ShouldContain("Foo");
                useNamespaces.Namespaces.ShouldContain("Bar");
            }
        }
示例#14
0
        private EmbeddedFubuMvcServer serverFor(Action <OwinSettings> action)
        {
            var registry = new FubuRegistry();

            registry.AlterSettings(action);
            return(FubuApplication.For(registry).StructureMap().RunEmbedded(port: 0));
        }
示例#15
0
        public void is_registered()
        {
            var registry = new FubuRegistry();

            registry.Import <ViewEnginesExtension>();
            registry.AlterSettings <CommonViewNamespaces>(x =>
            {
                x.Add("Foo");
                x.Add("Bar");
            });

            var graph         = BehaviorGraph.BuildFrom(registry);
            var useNamespaces = graph.Services.DefaultServiceFor <CommonViewNamespaces>().Value.As <CommonViewNamespaces>();

            useNamespaces.Namespaces.Each(x => Debug.WriteLine(x));

            useNamespaces.Namespaces.ShouldHaveTheSameElementsAs(new[]
            {
                typeof(VirtualPathUtility).Namespace,
                typeof(string).Namespace,
                typeof(FileSet).Namespace,
                typeof(ParallelQuery).Namespace,
                typeof(HtmlTag).Namespace,
                "Foo",
                "Bar",
            });
        }
示例#16
0
        public void blows_up_with_no_saml_certificate_repository()
        {
            var registry = new FubuRegistry();

            registry.AlterSettings <AuthenticationSettings>(_ =>
            {
                _.Enabled       = true;
                _.Saml2.Enabled = true;
            });

            var samlCertificateRepository = MockRepository.GenerateMock <ISamlCertificateRepository>();

            samlCertificateRepository.Stub(r => r.AllKnownCertificates())
            .Return(new SamlCertificate[0]);

            registry.Services.SetServiceIfNone <IPrincipalBuilder>(MockRepository.GenerateMock <IPrincipalBuilder>());
            registry.Services.AddService <ISamlResponseHandler>(MockRepository.GenerateMock <ISamlResponseHandler>());
            //registry.Services.SetServiceIfNone<ISamlCertificateRepository>(samlCertificateRepository);



            Exception <StructureMapConfigurationException> .ShouldBeThrownBy(() => {
                registry.ToRuntime();
            });
        }
        public void is_registered()
        {
            var registry = new FubuRegistry();
            registry.Import<ViewEnginesExtension>();
            registry.AlterSettings<CommonViewNamespaces>(x =>
            {
                x.Add("Foo");
                x.Add("Bar");
            });

            var graph = BehaviorGraph.BuildFrom(registry);
            var useNamespaces = graph.Services.DefaultServiceFor<CommonViewNamespaces>().Value.As<CommonViewNamespaces>();
            useNamespaces.Namespaces.Each(x => Debug.WriteLine(x));

            useNamespaces.Namespaces.ShouldHaveTheSameElementsAs(new[]
            { 
                typeof(VirtualPathUtility).Namespace,
                typeof(string).Namespace,
                typeof(FileSet).Namespace,
                typeof(ParallelQuery).Namespace,
                typeof(HtmlTag).Namespace,
                "Foo",
                "Bar",
            });
        }
        public void can_inject_the_right_html_on_GET_for_html_text()
        {
            var registry = new FubuRegistry();

            registry.AlterSettings <OwinSettings>(x =>
            {
                x.AddMiddleware <HtmlHeadInjectionMiddleware>().Arguments.With(new InjectionOptions
                {
                    Content = e => new HtmlTag("script").Attr("foo", "bar").ToString()
                });
            });

            using (var server = registry.ToRuntime())
            {
                server.Scenario(_ =>
                {
                    _.Get.Action <SimpleHtmlEndpoint>(x => x.get_html_content());

                    _.ContentShouldContain("<script foo=\"bar\"></script></head>");
                });

                server.Scenario(_ =>
                {
                    _.Get.Action <SimpleHtmlEndpoint>(x => x.get_text_content());

                    _.ContentShouldNotContain("<script foo=\"bar\"></script></head>");
                });
            }
        }
        public void see_tracing_logs_in_verbose_mode_happy_path()
        {
            var registry = new FubuRegistry();

            registry.ServiceBus.Enable(true);
            registry.Features.Diagnostics.Enable(TraceLevel.Verbose);
            registry.ServiceBus.EnableInMemoryTransport();
            registry.AlterSettings <LightningQueueSettings>(x => x.DisableIfNoChannels = true);

            using (var runtime = registry.ToRuntime())
            {
                var bus = runtime.Get <IServiceBus>();

                bus.Consume(new TracedInput());

                var history = runtime.Get <IChainExecutionHistory>();

                var log = history.RecentReports().Single(x => x.RootChain != null && x.RootChain.InputType() == typeof(TracedInput));

                log.Request["headers"].ShouldBeOfType <Dictionary <string, object> >();

                log.Steps.Any().ShouldBeTrue();
                log.Steps.Any(x => x.Log is StringMessage).ShouldBeTrue();

                log.Steps.Each(x => Debug.WriteLine(x));
            }
        }
示例#20
0
        public static void ViewFacility(this FubuRegistry registry, IViewFacility facility)
        {
            registry.AlterSettings <ViewEngines>(x => x.AddFacility(facility));

            registry.Policies.Add <ViewAttacher>();
            registry.Policies.Add <ActionlessViewConvention>();
        }
        public void Start()
        {
            _controller = _input.BuildRemoteController();
            var context = new StorytellerContext(_controller, _input);

            if (_controller.BinPath.IsEmpty())
            {
                throw new Exception("Could not determine any BinPath for the testing AppDomain. Has the Storyteller specification project been compiled, \nor is Storyteller using the wrong compilation target maybe?\n\ntype 'st.exe ? open' or st.exe ? run' to see the command usages\n\n");
            }

            context.Start();

            var registry = new FubuRegistry();


            registry.AlterSettings <DiagnosticsSettings>(_ => _.TraceLevel = TraceLevel.Verbose);
            registry.Mode = "development";
            registry.HostWith <NOWIN>();
            registry.Services.For <IRemoteController>().Use(_controller);
            registry.Services.For <StorytellerContext>().Use(context);

            registry.Services.IncludeRegistry <WebApplicationRegistry>();


            _server = registry.ToRuntime();
        }
示例#22
0
        protected override void configure(FubuRegistry registry)
        {
            registry.Actions.IncludeType <ProfileController>();

            // I want the default to work here.
            //registry.Views.TryToAttachWithDefaultConventions();
            registry.AlterSettings <ViewAttachmentPolicy>(x => x.Profile <Mobile>("m."));
        }
示例#23
0
        protected virtual void configure(FubuRegistry registry)
        {
            registry.Actions.IncludeType <SampleController>();


            registry.AlterSettings <AuthenticationSettings>(
                _ => _.Strategies.AddToEnd(MembershipNode.For <InMemoryMembershipRepository>()));
        }
        public void Configure(FubuRegistry registry)
        {
            registry.Services <AssetServicesRegistry>();
            registry.Policies.Add <AssetContentEndpoint>();

            registry.AlterSettings <CommonViewNamespaces>(x => {
                x.AddForType <AssetBottleRegistration>();
            });
        }
示例#25
0
        private FubuRuntime serverFor(Action <OwinSettings> action)
        {
            var registry = new FubuRegistry();

            registry.AlterSettings(action);
            registry.HostWith <Katana>();

            return(registry.ToRuntime());
        }
        public void Configure(FubuRegistry registry)
        {
            registry.Services<AssetServicesRegistry>();
            registry.Policies.Add<AssetContentEndpoint>();

            registry.AlterSettings<CommonViewNamespaces>(x => {
                x.AddForType<AssetBottleRegistration>();
            });
        }
        public void when_auto_import_is_false_namespaces_are_not_added()
        {
            _registry.AlterSettings <CommonViewNamespaces>(x => x.DontAutoImportWhenNamespaceStartsWith("Fubu"));

            var graph = BehaviorGraph.BuildFrom(_registry);
            var commonViewNamespaces = graph.Settings.Get <CommonViewNamespaces>();

            commonViewNamespaces.Namespaces.ShouldHaveTheSameElementsAs("FakeTestNamespaceForAutoImport");
        }
        public void when_auto_import_is_false_namespaces_are_not_added()
        {
            _registry.AlterSettings <CommonViewNamespaces>(x => x.DontAutoImportWhenNamespaceStartsWith("Fubu"));

            var graph = BehaviorGraph.BuildFrom(_registry);
            var commonViewNamespaces = graph.Settings.Get <CommonViewNamespaces>();

            commonViewNamespaces.Namespaces.ShouldContain("FakeTestNamespaceForAutoImport");
            commonViewNamespaces.Namespaces.ShouldNotContain(typeof(FakeAction).Namespace);
        }
示例#29
0
        public void SetUp()
        {
            var registry = new FubuRegistry();

            registry.AlterSettings <DiagnosticsSettings>(x => x.TraceLevel = TraceLevel.Verbose);

            graph = BehaviorGraph.BuildFrom(registry);
            urls  = MockRepository.GenerateMock <IUrlRegistry>();

            graph.Behaviors.Any().ShouldBeTrue();
        }
示例#30
0
        void IFubuRegistryExtension.Configure(FubuRegistry registry)
        {
            registry.ViewFacility(new RazorViewFacility(_templateRegistry, _parsings));
            registry.Services(configureServices);

            registry.AlterSettings <CommonViewNamespaces>(x =>
            {
                x.AddForType <RazorViewFacility>(); // FubuMVC.Razor
                x.AddForType <IPartialInvoker>();   // FubuMVC.Core.UI
            });
        }
示例#31
0
        public FubuApplication BuildApplication()
        {
            //throw new NotImplementedException("You suck!");

            var registry = new FubuRegistry();

            registry.AlterSettings <ConfigurationSettings>(x => {
                x.Include <ColorSettings>();
            });

            return(FubuApplication.For(registry).StructureMap(new Container()));
        }
示例#32
0
        public FubuApplication BuildApplication()
        {
            var registry = new FubuRegistry();

            registry.Import <DiagnosticApplication>();

            registry.AlterSettings <TransportSettings>(x => {
                x.DelayMessagePolling    = Int32.MaxValue;
                x.ListenerCleanupPolling = Int32.MaxValue;
            });

            return(FubuApplication.For(registry).StructureMap());
        }
示例#33
0
        void IFubuRegistryExtension.Configure(FubuRegistry registry)
        {
            IEnumerable <Type> markers = _markerTypes.Any()
                                                                                        ? _markerTypes
                                                                                        : new Type[] { registry.GetType() };

            var source = new HandlerActionSource(markers);

            registry.AlterSettings <UrlPolicies>(urls =>
            {
                urls.Policies.Insert(0, PolicyBuilder(markers.ToArray()));
            });
            registry.Actions.FindWith(source);
        }
        public void Configure(FubuRegistry registry)
        {
            registry.Configure(graph => {
                graph.Settings.Get<ViewEngines>().UseGraph(graph);
            });

            registry.AlterSettings<CommonViewNamespaces>(x =>
            {
                x.Add(typeof(VirtualPathUtility).Namespace); // System.Web
                x.AddForType<string>(); // System
                x.AddForType<FileSet>(); // FubuCore
                x.AddForType<ParallelQuery>(); // System.Linq
                x.AddForType<HtmlTag>(); // HtmlTags 
            });
        }
        public void do_not_use_the_excluded_views()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<ViewEngines>(x => {
                x.AddFacility(new FakeViewEngine1());
                x.AddFacility(new FakeViewEngine2());

                x.ExcludeViews(v => v.Name().StartsWith("A"));
                x.ExcludeViews(v => v.Name().StartsWith("C"));
            });

            var views = BehaviorGraph.BuildFrom(registry).Settings.Get<ViewEngines>().Views;

            views.Views.OrderBy(x => x.Name()).Select(x => x.Name())
                .ShouldHaveTheSameElementsAs("B1", "B2", "B3", "B4", "B5", "B6");
        }
示例#36
0
        void IFeatureSettings.Apply(FubuRegistry registry)
        {
            if (!Enabled) return;

            registry.Actions.FindWith<SendsMessageActionSource>();
            registry.Policies.Global.Add<SendsMessageConvention>();

            registry.Policies.Global.Add<ApplyScheduledJobRouting>();
            registry.Services.IncludeRegistry<ScheduledJobServicesRegistry>();
            registry.Services.IncludeRegistry<MonitoringServiceRegistry>();
            registry.Policies.ChainSource<SystemLevelHandlers>();
            registry.Services.IncludeRegistry(new FubuTransportServiceRegistry(registry.Mode));
            registry.Services.IncludeRegistry<PollingServicesRegistry>();
            registry.Policies.Global.Add<StatefulSagaConvention>();
            registry.Policies.Global.Add<AsyncHandlingConvention>();

            // Just forcing it to get spun up.
            registry.AlterSettings<ChannelGraph>(x => {});
            registry.Handlers.Include<SystemLevelHandlers>();

            registry.Configure(graph =>
            {
                graph.Handlers.Each(chain =>
                {
                    // 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);
                    }
                });
            });

            if (InMemoryTransport == InMemoryTransportMode.AllInMemory)
            {
                registry.Services.For<ITransport>().ClearAll();
                registry.Services.AddService<ITransport, InMemoryTransport>();

                SettingTypes.Each(settingType =>
                {
                    var settings = InMemory.InMemoryTransport.ToInMemory(settingType);
                    registry.Services.ReplaceService(settingType, new ObjectInstance(settings));
                });
            }

            if (InMemoryTransport != InMemoryTransportMode.Disabled)
            {
                registry.Services.AddService<ITransport, InMemoryTransport>();
            }

            registry.Policies.Global.Add<ReorderBehaviorsPolicy>(x =>
            {
                x.ThisNodeMustBeBefore<StatefulSagaNode>();
                x.ThisNodeMustBeAfter<HandlerCall>();
            });
        }