private void bakeBehaviorGraphIntoContainer(BehaviorGraph graph, IContainerFacility containerFacility) { graph.As <IRegisterable>().Register(_registry.Value.DiagnosticLevel, containerFacility.Register); // Important to register itself containerFacility.Register(typeof(IContainerFacility), ObjectDef.ForValue(containerFacility)); }
public void ImportInto(BehaviorGraph parent, ConfigLog log) { var childGraph = BehaviorGraphBuilder.Import(Registry, parent, log); parent.As<IChainImporter>().Import(childGraph, b => { b.PrependToUrl(Prefix); b.Origin = Registry.Name; }); log.Import(Registry.Config, Provenance); }
public void ImportInto(BehaviorGraph graph) { // TODO -- will want this to suck in the configuration log business somehow Registry.Compile(); BehaviorGraph childGraph = Registry.Configuration.BuildForImport(graph); graph.As<IChainImporter>().Import(childGraph, b => { b.PrependToUrl(Prefix); b.Origin = Registry.Name; }); }
public void ImportInto(BehaviorGraph parent, ConfigLog log) { var childGraph = BehaviorGraphBuilder.Import(Registry, parent, log); parent.As <IChainImporter>().Import(childGraph, b => { b.PrependToUrl(Prefix); b.Origin = Registry.Name; }); log.Import(Registry.Config, Provenance); }
public void ImportInto(BehaviorGraph graph) { // TODO -- will want this to suck in the configuration log business somehow Registry.Compile(); BehaviorGraph childGraph = Registry.Configuration.BuildForImport(graph); graph.As <IChainImporter>().Import(childGraph, b => { b.PrependToUrl(Prefix); b.Origin = Registry.Name; }); }
public void SetUp() { graph1 = new BehaviorGraph(null); graph2 = new BehaviorGraph(null); foo1 = new Foo(); foo2 = new Foo(); graph1.Services.AddService(foo1); graph2.Services.AddService(foo2); graph1.As <IChainImporter>().Import(graph2, b => b.PrependToUrl(string.Empty)); }
public void SetUp() { graph1 = new BehaviorGraph(); graph2 = new BehaviorGraph(); foo1 = new Foo(); foo2 = new Foo(); graph1.Services.AddService(foo1); graph2.Services.AddService(foo2); graph1.As <IChainImporter>().Import(graph2.Behaviors); }
public void RegisterService_can_be_called_multiple_times_to_store_multiple_implementations() { var graph = new BehaviorGraph(null); graph.Services.AddService <IRequestData, RequestData>(); graph.Services.AddService <IRequestData, InMemoryRequestData>(); var implementations = new List <Type>(); graph.As <IRegisterable>().Register((t, def) => { if (t == typeof(IRequestData)) { implementations.Add(def.Type); } }); implementations.ShouldContain(typeof(RequestData)); implementations.ShouldContain(typeof(InMemoryRequestData)); }
public void SetUp() { var builder = new ContainerBuilder(); builder.RegisterType<FileSystem>().As<IFileSystem>(); builder.RegisterInstance(MockRepository.GenerateMock<IStreamingData>()).As<IStreamingData>(); builder.RegisterInstance(new NulloHttpWriter()).As<IHttpWriter>(); builder.RegisterInstance(new CurrentChain(null, null)).As<ICurrentChain>(); builder.RegisterInstance( new StandInCurrentHttpRequest { ApplicationRoot = "http://server" }).As<ICurrentHttpRequest>(); builder.RegisterInstance(MockRepository.GenerateMock<IResourceHash>()).As<IResourceHash>(); builder.RegisterType<AutofacContainerFacility>().As<IContainerFacility>(); context = builder.Build(); graph = BehaviorGraph.BuildFrom( x => { x.Route("/area/sub/{Name}/{Age}") .Calls<TestController>(c => c.AnotherAction(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.AnotherAction(null)).OutputToJson(); x.Models.ConvertUsing<ExampleConverter>().ConvertUsing<ExampleConverter2>(); x.Services(s => s.AddService<IActivator>(new StubActivator())); x.Services(s => s.AddService<IActivator>(new StubActivator())); x.Services(s => s.AddService<IActivator>(new StubActivator())); }); facility = new AutofacContainerFacility(context); graph.As<IRegisterable>().Register(facility.Register); factory = facility.BuildFactory(); }
public void SetUp() { container = new Container(x => x.For<IFileSystem>().Use<FileSystem>()); graph = new FubuRegistry(x => { x.Route("/area/sub/{Name}/{Age}") .Calls<TestController>(c => c.AnotherAction(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.AnotherAction(null)).OutputToJson(); x.Models.ConvertUsing<ExampleConverter>().ConvertUsing<ExampleConverter2>(); x.Services(s => s.AddService<IActivator>(new StubActivator())); x.Services(s => s.AddService<IActivator>(new StubActivator())); x.Services(s => s.AddService<IActivator>(new StubActivator())); }).BuildGraph(); facility = new StructureMapContainerFacility(container); graph.As<IRegisterable>().Register(facility.Register); factory = facility.BuildFactory(DiagnosticLevel.None); }
private static void bakeBehaviorGraphIntoContainer(BehaviorGraph graph, IContainerFacility containerFacility) { graph.As <IRegisterable>().Register(containerFacility.Register); }
public void SetUp() { registry1 = new FubuRegistry(); registry1.Actions.IncludeType<RegistryImportEndpoint>(); theImport = new RegistryImport { Prefix = "area1", Registry = registry1 }; graph2 = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeType<TestController>(); }); graph2.As<IChainImporter>().Import(theImport.BuildChains(graph2.Settings)); }
public void SetUp() { container = new Container(x => { x.For<IFileSystem>().Use<FileSystem>(); x.For<IStreamingData>().Use(MockRepository.GenerateMock<IStreamingData>()); x.For<IHttpWriter>().Use(new NulloHttpWriter()); x.For<ICurrentChain>().Use(new CurrentChain(null, null)); x.For<ICurrentHttpRequest>().Use(new StubCurrentHttpRequest("http://server")); }); container.Configure(x => x.For<IContainerFacility>().Use<StructureMapContainerFacility>()); graph = new FubuRegistry(x => { x.Route("/area/sub/{Name}/{Age}") .Calls<TestController>(c => c.AnotherAction(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.AnotherAction(null)).OutputToJson(); x.Models.ConvertUsing<ExampleConverter>().ConvertUsing<ExampleConverter2>(); x.Services(s => s.AddService<IActivator>(new StubActivator())); x.Services(s => s.AddService<IActivator>(new StubActivator())); x.Services(s => s.AddService<IActivator>(new StubActivator())); }).BuildGraph(); facility = new StructureMapContainerFacility(container); graph.As<IRegisterable>().Register(DiagnosticLevel.None, facility.Register); factory = facility.BuildFactory(); }
public void SetUp() { container = new Container(x => { x.For<IFileSystem>().Use<FileSystem>(); x.For<IHttpResponse>().Use(new OwinHttpResponse()); x.For<ICurrentChain>().Use(new CurrentChain(null, null)); x.For<IHttpRequest>().Use(OwinHttpRequest.ForTesting()); x.For<IResourceHash>().Use(MockRepository.GenerateMock<IResourceHash>()); }); container.Configure(x => x.For<IContainerFacility>().Use<StructureMapContainerFacility>()); graph = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeType<TestController>(); // x.Route("/area/sub/{Name}/{Age}") // .Calls<TestController>(c => c.AnotherAction(null)); // // x.Route("/area/sub2/{Name}/{Age}") // .Calls<TestController>(c => c.AnotherAction(null)); // // x.Route("/area/sub3/{Name}/{Age}") // .Calls<TestController>(c => c.AnotherAction(null)); x.Models.ConvertUsing<ExampleConverter>().ConvertUsing<ExampleConverter2>(); x.Services(s => s.AddService<IActivator>(new StubActivator())); x.Services(s => s.AddService<IActivator>(new StubActivator())); x.Services(s => s.AddService<IActivator>(new StubActivator())); }); facility = new StructureMapContainerFacility(container); graph.As<IRegisterable>().Register(facility.Register); factory = facility.BuildFactory(); }