public static bool Serialize(string fileName, SerializationData data) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(SerializationData)); TextWriter textWriter = new StreamWriter(fileName); xmlSerializer.Serialize(textWriter, data); textWriter.Close(); return true; }
public static bool Deserialize(string fileName, out SerializationData data) { if (!File.Exists(fileName)) { data = null; return false; } XmlSerializer xmlDeserializer = new XmlSerializer(typeof(SerializationData)); TextReader textReader = new StreamReader(fileName); data = xmlDeserializer.Deserialize(textReader) as SerializationData; textReader.Close(); return true; }
public static bool SaveModel(string fileName = "") { if (fileName == "" && lastFileName == "") { return false; } string fName = lastFileName == "" ? fileName : lastFileName; SerializationData data = new SerializationData(); data.Nodes = Nodes; return SerializationData.Serialize(fName, data); }