using CoreUnit.Common; using GUI.Properties; using System; using System.IO; using System.Xml; namespace DB.Recipe { public class RecipeIndependant { public class IndependantParam { double m_heightZ; [XmlSerializable] public double HeightZ { get { return m_heightZ; } set { m_heightZ = value; } } public IndependantParam() { m_heightZ = 0; } } IndependantParam m_param = null; public IndependantParam Param { get { return m_param; } set { m_param = value; } } public RecipeIndependant() { m_param = new IndependantParam(); } public void Load() { FileInfo fi = new FileInfo(Settings.Default.DependantListParamFile); if (fi.Exists) { Load(Settings.Default.DependantListParamFile); } else { Save(); Load(Settings.Default.DependantListParamFile); } } public void Load(string fileName) { try { StreamReader sr = new StreamReader(fileName); XmlDocument doc = new XmlDocument(); doc.Load(sr); sr.Dispose(); XmlElement root = doc.DocumentElement; foreach (XmlElement node in root.ChildNodes) { if (node.Name == "property") { XmlUtil.ParseProperty(node, this); } if (node.Name == "items") { foreach (XmlElement itemNode in node.ChildNodes) { Object param = new RecipeIndependant(); XmlUtil.ParseProperties(itemNode, param); } } } } catch (Exception ex) { throw ex; } } public void Save() { Save(Settings.Default.DependantListParamFile); } public void Save(string fileName) { try { XmlTextWriter wr = new XmlTextWriter(fileName, null); wr.Formatting = Formatting.Indented; wr.WriteStartElement("DependantList");//1.레시피 항목 wr.WriteStartElement("items"); //2.Items 항목 XmlUtil.WriteProperties(Param, wr); wr.WriteEndElement();//3.ModelListParam 항목 wr.WriteEndElement();//2.Items 항목 wr.Close(); } catch (Exception ex) { throw ex; } } } }