public void SerializeToFile(ModelSet ModelSet, string filename) { StreamWriter fs = new StreamWriter(filename, false, Encoding.UTF8); fs.Write(Serilize(ModelSet)); fs.Close(); }
public string Serilize(ModelSet ModelSet) { StringWriterWithEncoding sw = new StringWriterWithEncoding(Encoding.UTF8); var writer = new XmlTextWriter(sw) { Formatting = Formatting.Indented }; writer.WriteStartDocument(); writer.WriteStartElement("AutoScript"); if (!string.IsNullOrEmpty(ModelSet.StartUrl)) { writer.WriteAttributeString("StartUrl", ModelSet.StartUrl); } if (!string.IsNullOrEmpty(ModelSet.Target)) { writer.WriteAttributeString("Target", ModelSet.Target); } writer.WriteAttributeString("DataMethod", ModelSet.DataMethod.ToString()); ModelSet.MainActionModel.SaveXml("MainAction", writer); ModelSet.SubActionModel.SaveXml("FunctionAction", writer); ModelSet.VariableActionModel.SaveXml("VariableAction", writer); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); return(sw.ToString()); }