public SleepEditDataReader(string path, SleepEditData data) { mSettings.IgnoreWhitespace = true; mSettings.IgnoreComments = true; reader = XmlReader.Create(path, mSettings); reader.ReadToFollowing("name"); if (reader.LocalName.Equals("name")) { data.TechNames.Add(reader.ReadString()); reader.Read(); while (reader.LocalName.Equals("name")) { data.TechNames.Add(reader.ReadString()); reader.Read(); } } reader.ReadToFollowing("maskStyle"); if (reader.LocalName.Equals("maskStyle")) { data.MaskStyles.Add(reader.ReadString()); reader.Read(); while (reader.LocalName.Equals("maskStyle")) { data.MaskStyles.Add(reader.ReadString()); reader.Read(); } } reader.ReadToFollowing("maskSize"); if (reader.LocalName.Equals("maskSize")) { data.MaskSizes.Add(reader.ReadString()); reader.Read(); while (reader.LocalName.Equals("maskSize")) { data.MaskSizes.Add(reader.ReadString()); reader.Read(); } } reader.Close(); }
public SleepEditDataWriter(string path, SleepEditData data) { mWriter = new XmlTextWriter(path, null); mData = data; mWriter.WriteStartDocument(); mWriter.WriteStartElement("sleepEditData"); mWriter.WriteStartElement("TechNames"); foreach (var techName in mData.TechNames) { mWriter.WriteStartElement("name"); mWriter.WriteValue(techName); mWriter.WriteEndElement(); } mWriter.WriteEndElement(); mWriter.WriteStartElement("MaskStyles"); foreach (var maskStyle in mData.MaskStyles) { mWriter.WriteStartElement("maskStyle"); mWriter.WriteValue(maskStyle); mWriter.WriteEndElement(); } mWriter.WriteEndElement(); mWriter.WriteStartElement("MaskSizes"); foreach (var maskSize in mData.MaskSizes) { mWriter.WriteStartElement("maskSize"); mWriter.WriteValue(maskSize); mWriter.WriteEndElement(); } mWriter.WriteEndElement(); mWriter.WriteEndElement(); mWriter.WriteEndDocument(); mWriter.Flush(); mWriter.Close(); }