// TOOD -- clean this up a little bit public static BehaviorGraph Build(FubuRegistry registry) { var graph = new BehaviorGraph {ApplicationAssembly = registry.ApplicationAssembly}; var config = registry.Config; PackageRegistry.Timer.Record("Applying Settings", () => applySettings(config, graph)); var assetDiscovery = AssetSettings.Build(graph); var viewDiscovery = graph.Settings.Get<ViewEngineSettings>().BuildViewBag(graph); var layoutAttachmentTasks = viewDiscovery.ContinueWith( t => graph.Settings.Get<ViewEngineSettings>().Facilities.Select(x => x.LayoutAttachment).ToArray()); graph.Settings.Replace(viewDiscovery); AccessorRulesCompiler.Compile(graph); var htmlConventionCollation = HtmlConventionCollator.BuildHtmlConventions(graph); addBuiltInDiagnostics(graph); PackageRegistry.Timer.Record("Local Application BehaviorGraph", () => config.BuildLocal(graph)); viewDiscovery.RecordContinuation("View Attachment",t => { var attacher = new ViewAttachmentWorker(t.Result, graph.Settings.Get<ViewAttachmentPolicy>()); attacher.Configure(graph); }).Wait(10.Seconds()); PackageRegistry.Timer.Record("Explicit Configuration", () => config.Global.Explicits.RunActions(graph)); PackageRegistry.Timer.Record("Global Policies", () => config.Global.Policies.RunActions(graph)); PackageRegistry.Timer.Record("Inserting Conneg and Authorization Nodes", () => insertConnegAndAuthorizationNodes(graph)); PackageRegistry.Timer.Record("Applying Global Reorderings", () => config.ApplyGlobalReorderings(graph)); PackageRegistry.Timer.Record("Applying Tracing", () => applyTracing(graph)); // Wait until all the other threads are done. var registration = htmlConventionCollation.ContinueWith(t => config.RegisterServices(graph)); Task.WaitAll(registration, layoutAttachmentTasks, assetDiscovery); Task.WaitAll(layoutAttachmentTasks.Result); new AutoImportModelNamespacesConvention().Configure(graph); return graph; }
public static BehaviorGraph Build(FubuRegistry registry) { var graph = new BehaviorGraph(); startBehaviorGraph(registry, graph); lookForAccessorOverrides(graph); var config = registry.Config; config.Add(new SystemServicesPack()); config.Add(new DefaultConfigurationPack()); // Apply settings config.RunActions(ConfigurationType.Settings, graph); var viewDiscovery = graph.Settings.Get<ViewEngines>().BuildViewBag(graph.Settings); discoverChains(config, graph); var attacher = new ViewAttachmentWorker(viewDiscovery.Result, graph.Settings.Get<ViewAttachmentPolicy>()); attacher.Configure(graph); config.RunActions(ConfigurationType.Explicit, graph); config.RunActions(ConfigurationType.Policy, graph); config.RunActions(ConfigurationType.InjectNodes, graph); config.RunActions(ConfigurationType.Attachment, graph); // apply the authorization, input, and output nodes graph.Behaviors.Each(x => x.InsertNodes(graph.Settings.Get<ConnegSettings>())); config.RunActions(ConfigurationType.Reordering, graph); config.RunActions(ConfigurationType.Instrumentation, graph); registerServices(config, graph); return graph; }