void ReadSetting(FactoryNode node, XElement element) { XAttribute nameAttr = element.Attribute("name"); XAttribute valueAttr = element.Attribute("value"); node.AddSetting(nameAttr.Value, valueAttr.Value); }
public static void BuildComponents(Factory parent, FactoryNode parentNode) { foreach (FactoryNode node in parentNode.components) { Factory factory = BuildFactory(parent, node); parent.AddChild(factory); } }
public static Factory BuildFactory(Factory parent, FactoryNode node) { Factory factory = Factory.ReflectionCreate(node.name); Part.Configure(factory, node.settings); BuildComponents(factory, node); return(factory); }
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); }
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); }
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)); }
// 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); } }
// 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); } }
// 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); } }
public void AddChild(FactoryNode node) { children.Add(node); }
public void AddComponent(FactoryNode node) { components.Add(node); }
void ReadChild(FactoryNode parent, XElement element) { FactoryNode node = ReadFactory(parent, element); parent.AddChild(node); }
void ReadComponent(FactoryNode parent, XElement element) { FactoryNode node = ReadFactory(parent, element); parent.AddComponent(node); }