Пример #1
0
        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;
        }
Пример #2
0
        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;
        }
Пример #3
0
        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);
        }