예제 #1
0
        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);
        }
예제 #3
0
        public static PluginGraph Build(this Registry registry)
        {
            var builder = new PluginGraphBuilder();
            builder.Add(registry);

            return builder.Build();
        }
예제 #4
0
        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());
        }
예제 #6
0
        public static PluginGraph BuildPluginGraphFromXml(string xml)
        {
            XmlDocument document = BuildDocument(xml);

            var builder = new PluginGraphBuilder();
            builder.Add(new ConfigurationParser(document.DocumentElement));
            return builder.Build();
        }
예제 #7
0
        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());
        }
예제 #10
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();
        }
예제 #11
0
        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();
        }
예제 #12
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);
            });
            
        }
예제 #14
0
        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();
        }
예제 #16
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 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);
        }
예제 #18
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();
        }
예제 #19
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();
        }
예제 #20
0
        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");
            }
        }
예제 #22
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);
        }
        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");
            }
        }
예제 #24
0
 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();
        }
예제 #26
0
        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;
        }
예제 #27
0
        public static PluginGraph GetDiagnosticPluginGraph(string fileName)
        {
            XmlDocument document = GetXmlDocument(fileName);

            return(PluginGraphBuilder.BuildFromXml(document));
        }
        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();
        }
예제 #29
0
 void IPluginGraphConfiguration.Register(PluginGraphBuilder builder)
 {
     _builders.Each(x => x(builder));
 }
예제 #30
0
        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);
            }
        }
예제 #31
0
        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;
 }
예제 #33
0
 public void Register(PluginGraphBuilder builder)
 {
     // no-op for now
 }
예제 #34
0
 void IPluginGraphConfiguration.Register(PluginGraphBuilder builder)
 {
     RegisterWasCalled = true;
 }