private void updateParam(XElement tmp, ParamModel param) { tmp.Attribute("Name").Value = param.name; tmp.Attribute("Type").Value = param.type.ToString(); tmp.Attribute("Val").Value = param.val; tmp.Attribute("Comment").Value = param.comment; }
public void SaveParam(ParamModel param) { XDocument xDoc = XDocument.Load(NameFile); bool flag = false; // записать foreach (XElement tmp in xDoc.Element("ProgramParam").Elements("level")) { foreach (XElement tmp1 in tmp.Elements("level")) { if ((tmp1.Attribute("Id").Value.ToString() == param.ParamID.ToString()) && (param.id == 0)) { writeParam(tmp1, param); break; } foreach (XElement tmp2 in tmp1.Elements("Param")) { if (param.id != 0) { if (tmp2.Attribute("Id").Value.ToString() == param.id.ToString()) { updateParam(tmp2, param); break; } } } } } xDoc.Save(NameFile); LoadData(); }
private void writeParam(XElement tmp, ParamModel param) { tmp.Add(new XElement("Param", new XAttribute("Id", getNewIndexParam()), new XAttribute("ParamID", param.ParamID), new XAttribute("Name", param.name), new XAttribute("Type", param.type), new XAttribute("Val", param.val), new XAttribute("Comment", param.comment) )); }