Esempio n. 1
0
        void ReadSetting(FactoryNode node, XElement element)
        {
            XAttribute nameAttr  = element.Attribute("name");
            XAttribute valueAttr = element.Attribute("value");

            node.AddSetting(nameAttr.Value, valueAttr.Value);
        }
Esempio n. 2
0
 public static void BuildComponents(Factory parent, FactoryNode parentNode)
 {
     foreach (FactoryNode node in parentNode.components)
     {
         Factory factory = BuildFactory(parent, node);
         parent.AddChild(factory);
     }
 }
Esempio n. 3
0
        public static Factory BuildFactory(Factory parent, FactoryNode node)
        {
            Factory factory = Factory.ReflectionCreate(node.name);

            Part.Configure(factory, node.settings);
            BuildComponents(factory, node);
            return(factory);
        }
Esempio n. 4
0
        public static FactoryNode Read(string filename)
        {
            FactoryReader reader = new FactoryReader();
            XDocument     doc    = XDocument.Load(filename);
            //
            XElement    element = doc.Element("root");
            FactoryNode root    = reader.ReadFactory(null, element);

            return(root);
        }
Esempio n. 5
0
        FactoryNode ReadFactory(FactoryNode parent, XElement element)
        {
            FactoryNode node     = new FactoryNode();
            XAttribute  nameAttr = element.Attribute("name");

            node.name = nameAttr.Value;
            ReadSettings(node, element);
            ReadComponents(node, element);
            ReadChildren(node, element);
            return(node);
        }
Esempio n. 6
0
        public static Factory Build(string name)
        {
            string filename = "../../../Content/production/" + name + ".xml";

            if (!File.Exists(filename))
            {
                return(null);
            }
            FactoryNode root = FactoryReader.Read(filename);

            return(BuildFactory(null, root));
        }
Esempio n. 7
0
        //
        void ReadChildren(FactoryNode parent, XElement element)
        {
            XElement childrenAtom = element.Element("children");

            if (childrenAtom == null)
            {
                return;
            }
            //else
            foreach (XElement childAtom in childrenAtom.Elements())
            {
                ReadComponent(parent, childAtom);
            }
        }
Esempio n. 8
0
        //
        void ReadComponents(FactoryNode parent, XElement element)
        {
            XElement componentsAtom = element.Element("components");

            if (componentsAtom == null)
            {
                return;
            }
            //else
            foreach (XElement componentAtom in componentsAtom.Elements())
            {
                ReadComponent(parent, componentAtom);
            }
        }
Esempio n. 9
0
        //
        void ReadSettings(FactoryNode node, XElement element)
        {
            XElement settingsAtom = element.Element("settings");

            if (settingsAtom == null)
            {
                return;
            }
            //else
            foreach (XElement settingAtom in settingsAtom.Elements())
            {
                ReadSetting(node, settingAtom);
            }
        }
Esempio n. 10
0
 public void AddChild(FactoryNode node)
 {
     children.Add(node);
 }
Esempio n. 11
0
 public void AddComponent(FactoryNode node)
 {
     components.Add(node);
 }
Esempio n. 12
0
        void ReadChild(FactoryNode parent, XElement element)
        {
            FactoryNode node = ReadFactory(parent, element);

            parent.AddChild(node);
        }
Esempio n. 13
0
        void ReadComponent(FactoryNode parent, XElement element)
        {
            FactoryNode node = ReadFactory(parent, element);

            parent.AddComponent(node);
        }