public static PluginGraph Build(this Registry registry)
        {
            var builder = new PluginGraphBuilder();
            builder.Add(registry);

            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 GetPluginGraph(string fileName)
        {
            XmlDocument document = GetXmlDocument(fileName);
            var parser = new ConfigurationParser(document.DocumentElement);
            var builder = new PluginGraphBuilder(parser);

            return builder.Build();
        }
Beispiel #4
0
        public static PluginGraph BuildPluginGraphFromXml(string xml)
        {
            XmlDocument document = BuildDocument(xml);

            var builder = new PluginGraphBuilder();
            builder.Add(new ConfigurationParser(document.DocumentElement));
            return builder.Build();
        }
Beispiel #5
0
        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();
        }
Beispiel #6
0
        public static PluginGraph GetPluginGraph(string fileName)
        {
            XmlDocument document = GetXmlDocument(fileName);
            var         parser   = new ConfigurationParser(document.DocumentElement);
            var         builder  = new PluginGraphBuilder();

            builder.Add(parser);

            return(builder.Build());
        }
Beispiel #7
0
        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();
        }
Beispiel #10
0
        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 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();
        }
        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);
        }
Beispiel #13
0
        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();
        }
Beispiel #14
0
        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();
        }
        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");
            }
        }
Beispiel #16
0
        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);
        }
        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 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 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();
        }
Beispiel #20
0
        public static PluginGraph GetPluginGraph(string fileName)
        {
            XmlDocument document = GetXmlDocument(fileName);
            var builder = new PluginGraphBuilder();
            builder.FindSource<XmlConfiguration>().IncludeNode(document.DocumentElement, "testing data");

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