The FubuRegistry class provides methods and grammars for configuring FubuMVC. Using a FubuRegistry subclass is the recommended way of configuring FubuMVC.
コード例 #1
0
ファイル: SparkExtension.cs プロジェクト: GunioRobot/fubumvc
        public void Configure(FubuRegistry registry)
        {
            locateTemplates();

            registry.Views.Facility(new SparkViewFacility(_composer));
            registry.Services(configureServices);
        }
コード例 #2
0
        protected override void configure(FubuRegistry registry)
        {
            registry.Actions.IncludeType<HelloRazorController>();

            registry.Views
                .TryToAttachWithDefaultConventions();
        }
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Import<ApplyWindowsAuthentication>();

            theGraph = BehaviorGraph.BuildFrom(registry);
        }
コード例 #4
0
        public void alter_settings_modifies_settings_object()
        {
            var registry = new FubuRegistry(r => r.AlterSettings<SettingsObject>(so => so.Touched = true));

            BehaviorGraph.BuildFrom(registry)
                .Settings.Get<SettingsObject>().Touched.ShouldBeTrue();
        }
        public void SetUp()
        {
            registry = new FubuRegistry(x =>
            {
                x.Actions.IncludeTypes(t => false);

                // Tell FubuMVC to wrap the behavior chain for each
                // RouteHandler with the "FakeUnitOfWorkBehavior"
                // Kind of like a global [ActionFilter] in MVC
                x.Policies.ConditionallyWrapBehaviorChainsWith<FakeUnitOfWorkBehavior>(
                    call => call.Method.Name == "SomeAction");

                // Explicit junk you would only do for exception cases to
                // override the conventions
                x.Route("area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.SomeAction(null)).OutputToJson();

                x.Route("area/sub2/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.ThirdAction(null)).OutputToJson();
            });

            _graph = BehaviorGraph.BuildFrom(registry);
        }
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Import<ServerSentEventsExtension>();

            theGraph = BehaviorGraph.BuildFrom(registry);
        }
コード例 #7
0
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<JsonController>();

            theGraph = registry.BuildGraph();
        }
コード例 #8
0
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Services<ResourcesServiceRegistry>();

            theServices = BehaviorGraph.BuildFrom(registry).Services;
        }
コード例 #9
0
        public void Configure(FubuRegistry registry)
        {
            registry.Policies.Add<MenuItemAttributeConfigurator>();
            registry.Policies.Add<CompileNavigationStep>();

            registry.Services<NavigationServiceRegistry>();
        }
コード例 #10
0
        public void Configure(FubuRegistry registry)
        {
            registry.Policies.Add<ApplyTracing>();
			registry.Policies.Add<DescriptionVisualizationPolicy>();
            registry.Policies.Add<DiagnosticChainsPolicy>();
            registry.Services<DiagnosticServiceRegistry>();

            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>();
                }
            });

            registry.Policies.Add<DefaultHome>();
        }
コード例 #11
0
 public void Configure(FubuRegistry registry)
 {
     registry.Policies.Add(policy => {
         policy.Where.LastActionMatches(call => call.HandlerType == typeof (AssemblyEndpoint));
         policy.Wrap.WithBehavior<BehaviorFromAssemblyBottle>();
     });
 }
コード例 #12
0
        public void SetUp()
        {
            registry = new FubuRegistry(x =>
            {
                x.Route<InputModel>("area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route<InputModel>("area/sub2/prop")
                    .Calls<TestController>(c => c.SomeAction(null)).OutputToJson();

                x.Route<InputModel>("area/sub2/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route<InputModel>("area/sub2/{Name}")
                    .Calls<TestController>(c => c.ThirdAction(null)).OutputToJson();

                x.Route<InputModel>("area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();
            });

            container = new Container();

            var bootstrapper = new StructureMapBootstrapper(container, registry);
            routes = new RouteCollection();

            bootstrapper.Bootstrap(routes);

            container.Configure(x => x.For<IOutputWriter>().Use(new InMemoryOutputWriter()));
            Debug.WriteLine(container.WhatDoIHave());
        }
コード例 #13
0
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Features.ServerSentEvents.Enable(true);

            theGraph = BehaviorGraph.BuildFrom(registry);
        }
コード例 #14
0
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Features.Localization.Enable(true);

            graphWithBasicLocalizationAsIs = BehaviorGraph.BuildFrom(registry);
        }
コード例 #15
0
        public void SetUp()
        {
            AssetDeclarationVerificationActivator.Latched = true;

            registry = new FubuRegistry(x =>
            {

                x.Route("area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub2/prop")
                    .Calls<TestController>(c => c.SomeAction(null)).OutputToJson();

                x.Route("area/sub2/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub2/{Name}")
                    .Calls<TestController>(c => c.ThirdAction(null)).OutputToJson();

                x.Route("area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub4/some_pattern")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();
            });

            container = new Container();

            routes = FubuApplication.For(registry).StructureMap(container).Bootstrap().Where(r => !r.As<Route>().Url.StartsWith("_content")).ToList();

            container.Configure(x => x.For<IOutputWriter>().Use(new InMemoryOutputWriter()));
            Debug.WriteLine(container.WhatDoIHave());
        }
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Import<YuiCompressionExtensions>();

            theServices = BehaviorGraph.BuildFrom(registry).Services;
        }
コード例 #17
0
 void IFubuRegistryExtension.Configure(FubuRegistry registry)
 {
     registry.Actions.FindWith<GoogleEndpoints>();
     registry.Services<GoogleServiceRegistry>();
     registry.Policies.Add<AttachDefaultGoogleView>();
     registry.Extensions().For(new OAuth2ContentExtension<GoogleLoginRequest>());
 }
コード例 #18
0
        public void Configure(FubuRegistry registry)
        {
            registry
                .Actions
                .FindWith<ExplicitControllerRegistration>();

            registry
                .Views
                .TryToAttachWithDefaultConventions()
                .TryToAttachViewsInPackages();

            registry
                .UseSpark(spark => spark.ConfigureComposer(c => c.AddBinder<DiagnosticsTemplateBinder>()));

            registry.Configure(graph =>
                                   {
                                       var chain = graph.FindHomeChain();
                                       if (chain == null)
                                       {
                                           graph
                                               .BehaviorFor<GettingStartedController>(x => x.Execute(new GettingStartedRequestModel()))
                                               .Route = new RouteDefinition(string.Empty);
                                       }
                                   });
        }
コード例 #19
0
        public void Configure(FubuRegistry registry)
        {
            registry.Policies.Global.Add<ApplyScheduledJobRouting>();
            registry.Services<ScheduledJobServicesRegistry>();
            registry.Services<MonitoringServiceRegistry>();
            registry.Policies.Global.Add<RegisterScheduledJobs>();
            registry.Policies.ChainSource<ImportHandlers>();
            registry.Services<FubuTransportServiceRegistry>();
            registry.Services<PollingServicesRegistry>();
            registry.Policies.Global.Add<RegisterPollingJobs>();
            registry.Policies.Global.Add<StatefulSagaConvention>();
            registry.Policies.Global.Add<AsyncHandlingConvention>();

            if (FubuTransport.AllQueuesInMemory)
            {
                registry.Policies.Global.Add<AllQueuesInMemoryPolicy>();
            }

            registry.Policies.Global.Add<InMemoryQueueRegistration>();

            registry.Policies.Global.Add<ReorderBehaviorsPolicy>(x =>
            {
                x.ThisNodeMustBeBefore<StatefulSagaNode>();
                x.ThisNodeMustBeAfter<HandlerCall>();
            });
        }
コード例 #20
0
 public void SetUp()
 {
     var registry = new FubuRegistry(x =>
     {
         //x.Route("some/route").Calls<ReportController>(o => o.BuildReport()).OutputToText();
     });
 }
コード例 #21
0
        public void SetUp()
        {
            registry = new FubuRegistry(x =>
            {

                // Tell FubuMVC to enrich the behavior chain for each
                // RouteHandler with the "FakeUnitOfWorkBehavior"
                // Kind of like a global [ActionFilter] in MVC
                x.Policies.EnrichCallsWith<FakeUnitOfWorkBehavior>(
                    call => call.Method.Name == "SomeAction");

                // Explicit junk you would only do for exception cases to
                // override the conventions
                x.Route<InputModel>("area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.SomeAction(null)).OutputToJson();

                x.Route<InputModel>("area/sub2/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route<InputModel>("area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.ThirdAction(null)).OutputToJson();
            });

            _graph = registry.BuildGraph();
        }
コード例 #22
0
        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 SetUp()
        {
            var registry = new FubuRegistry();
            registry.Services<ServerSentEventRegistry>();

            services = BehaviorGraph.BuildFrom(registry).Services;
        }
コード例 #24
0
        protected virtual void configure(FubuRegistry registry)
        {
            registry.Actions.IncludeType<SampleController>();

            registry.AlterSettings<AuthenticationSettings>(
                _ => _.Strategies.AddToEnd(MembershipNode.For<InMemoryMembershipRepository>()));
        }
コード例 #25
0
        public void beforeAll()
        {
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<Controller1>();

            _graph = BehaviorGraph.BuildFrom(registry);
        }
コード例 #26
0
 public void Configure(FubuRegistry registry)
 {
     registry.Services(s => s.AddService<IAssetPrecompiler, RequireJsAssetPrecompiler>());
     var requireJsAssetRegistry = new RequireJsAssetRegistry();
     registry.Services(s => s.SetServiceIfNone<IRequireJsAssetRegistry>(requireJsAssetRegistry));
     _actions.Each(x => x(registry));
 }
コード例 #27
0
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<RouteAliasController>();

            theGraph = BehaviorGraph.BuildFrom(registry);
        }
コード例 #28
0
        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, string>>();
                
                log.Steps.Any().ShouldBeTrue();
                log.Steps.Any(x => x.Log is StringMessage).ShouldBeTrue();

                log.Steps.Each(x => Debug.WriteLine(x));
            }
        }
コード例 #29
0
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<AuthorizedController2>();

            graph = BehaviorGraph.BuildFrom(registry);
        }
コード例 #30
0
 public void UseFakeSecurityContext(FubuRegistry registry)
 {
     if (FakeSecurityContext == null) {
         FakeSecurityContext = new FakeSecurityContext();
     }
     registry.Services(serviceRegistry => serviceRegistry.ReplaceService<ISecurityContext>(FakeSecurityContext));
 }
コード例 #31
0
ファイル: FubuRuntime.cs プロジェクト: zzekikaya/fubumvc
        public static FubuRuntime Basic(Action <FubuRegistry> configure = null)
        {
            var assembly = AssemblyFinder.FindTheCallingAssembly();
            var registry = new FubuRegistry(assembly);

            if (configure != null)
            {
                configure(registry);
            }

            return(new FubuRuntime(registry));
        }
コード例 #32
0
ファイル: ConfigurationGraph.cs プロジェクト: moacap/fubumvc
        public bool HasImported(FubuRegistry registry)
        {
            if (_imports.Any(x => x.Registry.GetType() == registry.GetType()))
            {
                return(true);
            }

            if (_imports.Any(x => x.Registry.Configuration.HasImported(registry)))
            {
                return(true);
            }

            return(false);
        }
コード例 #33
0
        public static BehaviorGraph Build(FubuRegistry registry)
        {
            var graph = new BehaviorGraph();

            startBehaviorGraph(registry, graph);
            var config = registry.Config;

            var log = new ConfigLog();

            graph.Services.AddService(log);
            log.Import(config);

            config.Add(new SystemServicesPack());
            config.Add(new DefaultConfigurationPack());

            // TODO -- log the provenance of all
            config.AllServiceRegistrations().Each(x => {
                x.Apply(graph.Services);
            });

            config.RunActions(ConfigurationType.Settings, graph);
            config.RunActions(ConfigurationType.Discovery, graph);

            config.UniqueImports().Each(import => import.ImportInto(graph, log));

            config.RunActions(ConfigurationType.Explicit, graph);
            config.RunActions(ConfigurationType.Policy, graph);
            config.RunActions(ConfigurationType.Attributes, graph);
            config.RunActions(ConfigurationType.ModifyRoutes, graph);
            config.RunActions(ConfigurationType.InjectNodes, graph);
            config.RunActions(ConfigurationType.Conneg, graph);
            config.RunActions(ConfigurationType.Attachment, graph);
            config.RunActions(ConfigurationType.Navigation, graph);
            config.RunActions(ConfigurationType.ByNavigation, graph);
            config.RunActions(ConfigurationType.Reordering, graph);
            config.RunActions(ConfigurationType.Instrumentation, graph);


            graph.Services.AddService(config);

            return(graph);
        }
コード例 #34
0
        // Need to track the ConfigLog
        public static BehaviorGraph Import(FubuRegistry registry, BehaviorGraph parent, ConfigLog log)
        {
            var graph = BehaviorGraph.ForChild(parent);

            startBehaviorGraph(registry, graph);
            var config = registry.Config;

            config.RunActions(ConfigurationType.Settings, graph);
            config.RunActions(ConfigurationType.Discovery, graph);

            config.Imports.Each(import => import.ImportInto(graph, log));

            config.RunActions(ConfigurationType.Explicit, graph);
            config.RunActions(ConfigurationType.Policy, graph);
            config.RunActions(ConfigurationType.Reordering, graph);
            config.RunActions(ConfigurationType.Attributes, graph);
            config.RunActions(ConfigurationType.ModifyRoutes, graph);
            config.RunActions(ConfigurationType.InjectNodes, graph);
            config.RunActions(ConfigurationType.Conneg, graph);

            return(graph);
        }
コード例 #35
0
ファイル: FubuRuntime.cs プロジェクト: zzekikaya/fubumvc
        private void applyFubuExtensionsFromPackages(IActivationDiagnostics diagnostics,
                                                     IEnumerable <Assembly> packageAssemblies, FubuRegistry registry)
        {
            // THIS IS NEW, ONLY ASSEMBLIES MARKED AS [FubuModule] will be scanned
            var importers = packageAssemblies.Where(a => a.HasAttribute <FubuModuleAttribute>()).Select(
                assem => Task.Factory.StartNew(() => assem.FindAllExtensions(diagnostics))).ToArray();

            Task.WaitAll(importers, 5.Seconds());

            importers.SelectMany(x => x.Result).Each(x => x.Apply(registry));
        }
コード例 #36
0
ファイル: FubuRuntime.cs プロジェクト: zzekikaya/fubumvc
        public FubuRuntime(FubuRegistry registry)
        {
            _registry = registry;

            _appFunc = new Lazy <AppFunc>(() => FubuOwinHost.ToAppFunc(this));

            RouteTable.Routes.Clear();

            _diagnostics = new ActivationDiagnostics();

            _perfTimer = _diagnostics.Timer;
            _perfTimer.Start("FubuRuntime Bootstrapping");


            var packageAssemblies = AssemblyFinder.FindModuleAssemblies(_diagnostics);

            var applicationPath = registry.RootPath ?? DefaultApplicationPath();

            _files = new FubuApplicationFiles(applicationPath);

            _perfTimer.Record("Applying IFubuRegistryExtension's",
                              () => applyFubuExtensionsFromPackages(_diagnostics, packageAssemblies, registry));

            _container = registry.ToContainer();

            var graph = _perfTimer.Record("Building the BehaviorGraph",
                                          () => BehaviorGraphBuilder.Build(registry, _perfTimer, packageAssemblies, _diagnostics, _files));

            _perfTimer.Record("Registering services into the IoC Container",
                              () => registry.Config.RegisterServices(Mode, _container, graph));

            _factory = new StructureMapServiceFactory(_container);

            var routeTask = _perfTimer.RecordTask("Building Routes", () =>
            {
                var routes = buildRoutes(_factory, graph);
                routes.Each(r => RouteTable.Routes.Add(r));

                return(routes);
            });

            var library = HtmlConventionCollator.BuildHtmlConventions(graph);

            _container.Configure(_ =>
            {
                _.Policies.OnMissingFamily <SettingPolicy>();

                _.For <IFubuApplicationFiles>().Use(_files);
                _.For <IServiceLocator>().Use <StructureMapServiceLocator>();
                _.For <FubuRuntime>().Use(this);
                _.For <IServiceFactory>().Use(_factory);
                _.For <HtmlConventionLibrary>().Use(library);
            });


            Activate();

            _routes = routeTask.Result();



            if (registry.Host != null)
            {
                startHosting();
            }

            _perfTimer.Stop();
            Restarted = DateTime.Now;

            _diagnostics.AssertNoFailures();
        }
コード例 #37
0
ファイル: FubuExtensionFinder.cs プロジェクト: xeno3/fubumvc
 public void Apply(FubuRegistry registry)
 {
     _log.Trace("Applying extension " + typeof(T).FullName);
     registry.Import <T>();
 }
コード例 #38
0
ファイル: FubuRegistry.cs プロジェクト: zzekikaya/fubumvc
 public HandlersExpression(FubuRegistry parent)
 {
     _parent = parent;
 }
コード例 #39
0
 public static IContainerFacilityExpression For(FubuRegistry registry)
 {
     return(new FubuApplication(() => registry));
 }
コード例 #40
0
ファイル: FubuBootstrapper.cs プロジェクト: pjdennis/fubumvc
 public FubuBootstrapper(IContainerFacility facility, FubuRegistry topRegistry)
 {
     _facility    = facility;
     _topRegistry = topRegistry;
 }
コード例 #41
0
ファイル: ConfigurationGraph.cs プロジェクト: moacap/fubumvc
 public ConfigurationGraph(FubuRegistry registry)
 {
     _registry = registry;
 }
コード例 #42
0
 private static void startBehaviorGraph(FubuRegistry registry, BehaviorGraph graph)
 {
     graph.ApplicationAssembly = registry.ApplicationAssembly;
     registry.Config.Add(new DiscoveryActionsConfigurationPack());
 }
コード例 #43
0
 public void Apply(FubuRegistry registry)
 {
     registry.Import <T>();
 }
コード例 #44
0
 private FubuRegistry registry()
 {
     return(_registryCache ?? (_registryCache = _registryBuilder()));
 }
コード例 #45
0
 public void Apply(FubuRegistry registry, IPackageLog packageLog)
 {
     packageLog.Trace("Applying extension " + typeof(T).FullName);
     registry.Import <T>();
 }
コード例 #46
0
 public static void ApplyExtensions(FubuRegistry registry, IEnumerable <Assembly> assemblies)
 {
     FindAllExtensionTypes(assemblies).Select(type => typeof(Importer <>).CloseAndBuildAs <IImporter>(type)).Each(
         x => x.Apply(registry));
 }
コード例 #47
0
 public OutputDeterminationExpression(FubuRegistry registry)
 {
     _registry = registry;
 }
コード例 #48
0
ファイル: ConfigGraph.cs プロジェクト: chester89/fubumvc
 public void Push(FubuRegistry registry)
 {
     _currentProvenance = _currentProvenance.Push(new FubuRegistryProvenance(registry));
 }