public PluginGraph ToPluginGraph() { var builder = new PluginGraphBuilder(); builder.AddScanner(this); return(builder.Build()); }
public void FindRegistriesWithinPluginGraphSeal() { var builder = new PluginGraphBuilder(); var registry = new Registry(); registry.Scan(x => { x.AssemblyContainingType(typeof(RedGreenRegistry)); x.LookForRegistries(); }); builder.AddConfiguration(registry); var graph = builder.Build(); var colors = new List<string>(); PluginFamily family = graph.FindFamily(typeof (IWidget)); family.Instances.Each(instance => colors.Add(instance.Name)); Assert.Contains("Red", colors); Assert.Contains("Green", colors); Assert.Contains("Yellow", colors); Assert.Contains("Blue", colors); Assert.Contains("Brown", colors); Assert.Contains("Black", colors); }
public static PluginGraph Build(this Registry registry) { var builder = new PluginGraphBuilder(); builder.Add(registry); return builder.Build(); }
internal DependencyContainer(List <Registry> modules) { var builder = new PluginGraphBuilder(); modules.ForEach(e => builder.Add(e)); container = new Container(builder.Build()); }
public static PluginGraph GetPluginGraph(string fileName) { XmlDocument document = GetXmlDocument(fileName); var parser = new ConfigurationParser(document.DocumentElement); var builder = new PluginGraphBuilder(parser); return(builder.Build()); }
public static PluginGraph BuildPluginGraphFromXml(string xml) { XmlDocument document = BuildDocument(xml); var builder = new PluginGraphBuilder(); builder.Add(new ConfigurationParser(document.DocumentElement)); return builder.Build(); }
public static PluginGraph GetPluginGraph(string fileName) { XmlDocument document = GetXmlDocument(fileName); var parser = new ConfigurationParser(document.DocumentElement); var builder = new PluginGraphBuilder(parser); return builder.Build(); }
public static PluginGraph Build(this Registry registry) { var builder = new PluginGraphBuilder(); builder.Add(registry); return(builder.Build()); }
public static PluginGraph BuildPluginGraphFromXml(string xml) { XmlDocument document = BuildDocument(xml); var parser = new ConfigurationParser(document.DocumentElement); var builder = new PluginGraphBuilder(parser); return(builder.Build()); }
public static PluginGraph BuildPluginGraphFromXml(string xml) { XmlDocument document = BuildDocument(xml); var builder = new PluginGraphBuilder(); builder.FindSource<XmlConfiguration>().IncludeNode(document.DocumentElement, "testing data"); return builder.Build(); }
public static PluginGraph GetDiagnosticPluginGraph(string fileName) { XmlDocument document = GetXmlDocument(fileName); var log = new GraphLog(); var builder = new PluginGraphBuilder(); builder.FindSource<XmlConfiguration>().IncludeNode(document.DocumentElement, "testing data"); return builder.Build(); }
public static PluginGraph BuildGraphFromAssembly(Assembly assembly) { var builder = new PluginGraphBuilder(); var scanner = new AssemblyScanner(); scanner.Assembly(assembly); builder.AddScanner(scanner); return(builder.Build()); }
private StructureMapException assertErrorIsThrown(string xml, Action<Container> action) { var document = new XmlDocument(); document.LoadXml(xml.Replace("\"", "'")); var builder = new PluginGraphBuilder(); builder.Add(new ConfigurationParser(document.DocumentElement)); var container = new Container(builder.Build()); return Exception<StructureMapException>.ShouldBeThrownBy(() => { action(container); }); }
private void Scan(Action <AssemblyScanner> action) { var scanner = new AssemblyScanner(); action(scanner); scanner.ExcludeNamespaceContainingType <ScanningRegistry>(); scanner.Convention <FakeConvention>(); var builder = new PluginGraphBuilder(); builder.AddScanner(scanner); theGraph = builder.Build(); }
public void SetUp() { DataMother.WriteDocument("FullTesting.XML"); var doc = new XmlDocument(); doc.Load("StructureMap.config"); XmlNode node = doc.DocumentElement.SelectSingleNode("//StructureMap"); var parser = new ConfigurationParser(node); var builder = new PluginGraphBuilder(parser); graph = builder.Build(); }
private StructureMapException assertErrorIsThrown(string xml, Action <Container> action) { var document = new XmlDocument(); document.LoadXml(xml.Replace("\"", "'")); var builder = new PluginGraphBuilder(); builder.Add(new ConfigurationParser(document.DocumentElement)); var container = new Container(builder.Build()); return(Exception <StructureMapException> .ShouldBeThrownBy(() => { action(container); })); }
public void SwitchToAttributeNormalizedMode() { XmlDocument document = DataMother.GetXmlDocument("AttributeNormalized.xml"); var parser = new ConfigurationParser(document.DocumentElement); var builder = new PluginGraphBuilder(parser); PluginGraph graph = builder.Build(); var manager = new Container(graph); var tommy = (GrandChild) manager.GetInstance(typeof (GrandChild), "Tommy"); Assert.AreEqual(false, tommy.RightHanded); Assert.AreEqual(1972, tommy.BirthYear); var blue = (ColorWidget) manager.GetInstance(typeof (IWidget), "Blue"); Assert.AreEqual("Blue", blue.Color); }
private void Scan(Action <IAssemblyScanner> action) { var registry = new Registry(); registry.Scan(scan => { action(scan); scan.ExcludeNamespaceContainingType <ScanningRegistry>(); scan.Convention <FakeConvention>(); }); var builder = new PluginGraphBuilder(); builder.Add(registry); theGraph = builder.Build(); }
private void Scan(Action <AssemblyScanner> action) { var scanner = new AssemblyScanner(); scanner.Convention <FamilyAttributeScanner>(); scanner.Convention <PluggableAttributeScanner>(); action(scanner); scanner.ExcludeNamespaceContainingType <ScanningRegistry>(); var builder = new PluginGraphBuilder(); builder.AddScanner(scanner); theGraph = builder.Build(); theGraph.Log.AssertFailures(); }
public void CanGetPluginFamilyFromPluginGraphWithNoParameters() { var builder = new PluginGraphBuilder(); var scanner = new AssemblyScanner(); scanner.Assembly(GetType().Assembly); builder.AddScanner(scanner); var graph = builder.Build(); graph.Families[typeof(IGenericService <int>)].ShouldBeTheSameAs( graph.Families[typeof(IGenericService <int>)]); graph.Families[typeof(IGenericService <string>)].ShouldBeTheSameAs( graph.Families[typeof(IGenericService <string>)]); graph.Families[typeof(IGenericService <>)].ShouldBeTheSameAs( graph.Families[typeof(IGenericService <>)]); }
private void assertErrorIsThrown(int errorCode, string xml, Action<Container> action) { var document = new XmlDocument(); document.LoadXml(xml.Replace("\"", "'")); var builder = new PluginGraphBuilder(); builder.Add(new ConfigurationParser(document.DocumentElement)); var manager = new Container(builder.Build()); try { action(manager); Assert.Fail("Should have thrown exception"); } catch (StructureMapException ex) { Assert.AreEqual(errorCode, ex.ErrorCode, "Expected error code"); } }
public void SwitchToAttributeNormalizedMode() { XmlDocument document = DataMother.GetXmlDocument("AttributeNormalized.xml"); var parser = new ConfigurationParser(document.DocumentElement); var builder = new PluginGraphBuilder(parser); PluginGraph graph = builder.Build(); var manager = new Container(graph); var tommy = (GrandChild)manager.GetInstance(typeof(GrandChild), "Tommy"); Assert.AreEqual(false, tommy.RightHanded); Assert.AreEqual(1972, tommy.BirthYear); var blue = (ColorWidget)manager.GetInstance(typeof(IWidget), "Blue"); Assert.AreEqual("Blue", blue.Color); }
private void assertErrorIsThrown(int errorCode, string xml, Action <Container> action) { var document = new XmlDocument(); document.LoadXml(xml.Replace("\"", "'")); var parser = new ConfigurationParser(document.DocumentElement); var builder = new PluginGraphBuilder(parser); var manager = new Container(builder.Build()); try { action(manager); Assert.Fail("Should have thrown exception"); } catch (StructureMapException ex) { Assert.AreEqual(errorCode, ex.ErrorCode, "Expected error code"); } }
public void Register(PluginGraphBuilder builder) { // no-op for now }
public void SetUp() { DataMother.WriteDocument("FullTesting.XML"); var doc = new XmlDocument(); doc.Load("StructureMap.config"); XmlNode node = doc.DocumentElement.SelectSingleNode("//StructureMap"); var builder = new PluginGraphBuilder(); builder.FindSource<XmlConfiguration>().IncludeNode(node, "testing data"); graph = builder.Build(); }
public IEnumerable<IConfigurationSource> DiscoveredConfigurations(PluginGraphBuilder builder) { ConfigurationParser[] parsers = GetParsers(builder.Log); var graphBuilder = new GraphBuilder(builder.Graph); foreach (var p in parsers) { builder.Log.StartSource(p.Description); p.ParseRegistries(graphBuilder); } return graphBuilder.DiscoveredConfigurations; }
public static PluginGraph GetDiagnosticPluginGraph(string fileName) { XmlDocument document = GetXmlDocument(fileName); return(PluginGraphBuilder.BuildFromXml(document)); }
void IPluginGraphConfiguration.Register(PluginGraphBuilder builder) { _builders.Each(x => x(builder)); }
public void Configure(PluginGraphBuilder builder) { ConfigurationParser[] parsers = GetParsers(builder.Log); var graphBuilder = new GraphBuilder(builder.Graph); foreach (var p in parsers) { builder.Log.StartSource(p.Description); p.Parse(graphBuilder); } }
public IEnumerable<AssemblyScanner> GetScanners(PluginGraphBuilder builder) { ConfigurationParser[] parsers = GetParsers(builder.Log); var graphBuilder = new GraphBuilder(builder.Graph); foreach (var p in parsers) { builder.Log.StartSource(p.Description); p.ParseRegistries(graphBuilder); p.ParseAssemblies(graphBuilder); } yield return graphBuilder.AssemblyScanner; }
void IPluginGraphConfiguration.Register(PluginGraphBuilder builder) { RegisterWasCalled = true; }