public RootPipelineGraph(PluginGraph pluginGraph) { _pluginGraph = pluginGraph; _transientCache = new NulloTransientCache(); _profiles = new Cache <string, IPipelineGraph>( name => new ComplexPipelineGraph(this, _pluginGraph.Profile(name), new NulloTransientCache())); }
public Profiles(PluginGraph pluginGraph, IPipelineGraph root) { _profiles = new Cache <string, IPipelineGraph>(name => { var profileGraph = pluginGraph.Profile(name); var instances = new ComplexInstanceGraph(root, profileGraph, ContainerRole.ProfileOrChild); return(new PipelineGraph(profileGraph, instances, root, root.Singletons, root.Transients)); }); }
public IPipelineGraph For(string profileName) { return(_profiles.GetOrAdd(profileName, key => { var profileGraph = _pluginGraph.Profile(profileName); var instances = new ComplexInstanceGraph(_root, profileGraph, ContainerRole.ProfileOrChild); return new PipelineGraph(profileGraph, instances, _root, _root.Singletons, _root.Transients); })); }
public void find_root() { var top = new PluginGraph(); var node = top.Profile("Foo"); var leaf = node.Profile("Bar"); top.Root.ShouldBeTheSameAs(top); node.Root.ShouldBeTheSameAs(top); leaf.Root.ShouldBeTheSameAs(top); }
public void lifecycle_for_pluginType_explicitly_set() { var graph = new PluginGraph(); var profile = graph.Profile("Red"); profile.Families[typeof(IGateway)].SetLifecycleTo <SingletonLifecycle>(); var pipeline = PipelineGraph.BuildRoot(graph).Profiles.For("Red"); pipeline.Instances.DefaultLifecycleFor(typeof(IGateway)) .ShouldBeOfType <SingletonLifecycle>(); }
public void get_the_owner_when_part_of_a_deep_profile() { var graph = new PluginGraph(); var profile = graph.Profile("something").Profile("else").Profile("again"); var family = profile.Families[GetType()]; var instance = new SimpleInstance(); family.AddInstance(instance); instance.Owner().ShouldBeTheSameAs(graph); }
public void Add_default_instance_with_literal() { var registry = new Registry(); var theWidget = new AWidget(); string theProfileName = "something"; registry.Profile(theProfileName, p => { p.For <IWidget>().Use(theWidget); }); PluginGraph graph = registry.Build(); graph.Profile("something").Families[typeof(IWidget)].GetDefaultInstance() .ShouldBeOfType <ObjectInstance>() .Object.ShouldBeTheSameAs(theWidget); }
public IPipelineGraph For(string profileName, object syncLock) { if (!_profiles.ContainsKey(profileName)) { lock (syncLock) { if (!_profiles.ContainsKey(profileName)) { var profileGraph = _pluginGraph.Profile(profileName); var instances = new ComplexInstanceGraph(_root, profileGraph, ContainerRole.ProfileOrChild); var pipeline = new PipelineGraph(profileGraph, instances, _root, _root.Singletons, _root.Transients); Container.CorrectSingletonLifecycleForChild(pipeline); _profiles[profileName] = pipeline; } } } return(_profiles[profileName]); }