public PluginGraphBuilder(ConfigurationParser[] parsers, Registry[] registries, GraphLog log)
 {
     _parsers = parsers;
     _registries = registries;
     _graph = new PluginGraph();
     _graph.Log = log;
 }
        public void IncludeNode(XmlNode node, string description)
        {
            var parser = new ConfigurationParser(node);

            parser.Description = description;

            _parsers.Add(parser);
        }
        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 parser = new ConfigurationParser(document.DocumentElement);
            var builder = new PluginGraphBuilder(parser);
            return builder.Build();
        }
        public void SetUp()
        {
            var doc = new XmlDocument();
            doc.LoadXml(xml);

            var parser = new ConfigurationParser(doc.DocumentElement);

            var builder = new GraphBuilder(new Registry[0]);
            parser.ParseProfilesAndMachines(builder);
        }
        public void SetUp()
        {
            var doc = new XmlDocument();
            doc.LoadXml(xml);

            var parser = new ConfigurationParser(doc.DocumentElement);

            var builder = new GraphBuilder(new PluginGraph());
            parser.ParseProfiles(builder);
        }
 private void addConfigurationFromIncludeNodes(List <ConfigurationParser> list)
 {
     foreach (ConfigurationParser parser in list.ToArray())
     {
         parser.ForEachFile(_log, filename => _log.Try(() =>
         {
             ConfigurationParser childParser = ConfigurationParser.FromFile(filename);
             list.Add(childParser);
         })
                            .AndReportErrorAs(150, filename));
     }
 }
 private void addConfigurationFromExplicitlyAddedFiles(ICollection <ConfigurationParser> list)
 {
     foreach (string filename in _otherFiles)
     {
         string absolutePath = locateFileAsAbsolutePath(filename);
         _log.Try(() =>
         {
             ConfigurationParser parser = ConfigurationParser.FromFile(absolutePath);
             parser.Description         = absolutePath;
             list.Add(parser);
         }).AndReportErrorAs(160, absolutePath);
     }
 }
        public static ConfigurationParser FromFile(string filename)
        {
            var document = new XmlDocument();
            document.Load(filename);

            XmlNode structureMapNode = document.SelectSingleNode("//" + STRUCTUREMAP);
            if (structureMapNode == null)
            {
                throw new StructureMapException(155, filename);
            }

            var parser = new ConfigurationParser(structureMapNode);
            parser.FilePath = filename;

            return parser;
        }
        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 addConfigurationFromStructureMapConfig(ICollection <ConfigurationParser> list)
        {
            if (_ignoreDefaultFile)
            {
                return;
            }
            // Pick up the configuration in the default StructureMap.config
            string pathToStructureMapConfig = GetStructureMapConfigurationPath();

            if ((_useAndEnforceExistenceOfDefaultFile || File.Exists(pathToStructureMapConfig)))
            {
                _log.Try(() =>
                {
                    ConfigurationParser parser = ConfigurationParser.FromFile(pathToStructureMapConfig);
                    list.Add(parser);
                }).AndReportErrorAs(100, pathToStructureMapConfig);
            }
        }
        public static ConfigurationParser FromFile(string filename)
        {
            var document = new XmlDocument();

            document.Load(filename);

            XmlNode structureMapNode = document.SelectSingleNode("//" + STRUCTUREMAP);

            if (structureMapNode == null)
            {
                throw new StructureMapException(155, filename);
            }

            var parser = new ConfigurationParser(structureMapNode);

            parser.FilePath = filename;

            return(parser);
        }
        public void IncludeNode(XmlNode node, string description)
        {
            var parser = new ConfigurationParser(node);
            parser.Description = description;

            _parsers.Add(parser);
        }
        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 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 PluginGraphBuilder(ConfigurationParser parser)
     : this(new[] {parser}, new Registry[0], new GraphLog())
 {
 }