2026-06-05 13:44:39 +09:00

119 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.IO;
using CoreUnit.Common;
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(Properties.Settings.Default.DependantListParamFile);
if (fi.Exists)
{
Load(Properties.Settings.Default.DependantListParamFile);
}
else
{
Save();
Load(Properties.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(Properties.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;
}
}
}
}