Exemple #1
0
        public void Save(List <Figure> figures)
        {
            Serializer serializer = new Serializer();
            string     yamlString = serializer.Serialize(FigureSerializer.GetMementoList(figures));

            File.WriteAllText(path, yamlString);
        }
Exemple #2
0
        public void Save(List <Figure> figures)
        {
            TextWriter    writer     = File.CreateText(path);
            XmlSerializer serializer = new XmlSerializer(typeof(List <FigureMemento>));

            serializer.Serialize(writer, FigureSerializer.GetMementoList(figures));
            writer.Close();
        }
 public void Save(List <Figure> figures)
 {
     using (Stream stream = File.Open(path, FileMode.Create))
     {
         BinaryFormatter bformatter = new BinaryFormatter();
         bformatter.Serialize(stream, FigureSerializer.GetMementoList(figures));
     }
 }
        public List <Figure> Open()
        {
            if (File.Exists(path) == false)
            {
                FileStream fs = File.Create(path);
                fs.Close();
            }
            string csvString = File.ReadAllText(path);
            List <FigureMemento> mFigures = new List <FigureMemento>();

            if (csvString.Length != 0)
            {
                mFigures = CsvSerializer.DeserializeFromString <List <FigureMemento> >(csvString);
            }

            return(FigureSerializer.GetFiguresList(mFigures));
        }
        public List <Figure> Open()
        {
            if (File.Exists(path) == false)
            {
                FileStream fs = File.Create(path);
                fs.Close();
            }
            string jsonString            = File.ReadAllText(path);
            List <FigureMemento> figures = new List <FigureMemento>();

            if (jsonString.Length != 0)
            {
                figures = JsonConvert.DeserializeObject <List <FigureMemento> >(jsonString);
            }

            return(FigureSerializer.GetFiguresList(figures));
        }
        public List <Figure> Open()
        {
            if (File.Exists(path) == false)
            {
                FileStream fs = File.Create(path);
                fs.Close();
                return(new List <Figure>());
            }
            List <FigureMemento> lf = new List <FigureMemento>();

            using (Stream stream = File.Open(path, FileMode.Open))
            {
                BinaryFormatter bformatter = new BinaryFormatter();
                lf = (List <FigureMemento>)bformatter.Deserialize(stream);
            }
            return(FigureSerializer.GetFiguresList(lf));
        }
Exemple #7
0
        public List <Figure> Open()
        {
            if (File.Exists(path) == false)
            {
                FileStream fs = File.Create(path);
                fs.Close();
            }
            string yamlString                 = File.ReadAllText(path);
            List <FigureMemento> figures      = new List <FigureMemento>();
            Deserializer         deserializer = new Deserializer();

            if (yamlString.Length != 0)
            {
                figures = deserializer.Deserialize <List <FigureMemento> >(yamlString);
            }

            return(FigureSerializer.GetFiguresList(figures));
        }
Exemple #8
0
        public List <Figure> Open()
        {
            if (File.Exists(path) == false)
            {
                FileStream fs = File.Create(path);
                fs.Close();
            }
            TextReader reader = File.OpenText(path);

            XmlSerializer        serializer = new XmlSerializer(typeof(List <FigureMemento>));
            List <FigureMemento> figures    = new List <FigureMemento>();

            try
            {
                figures = (List <FigureMemento>)serializer.Deserialize(reader);
            }
            catch (Exception)
            {
                figures = new List <FigureMemento>();
            }

            reader.Close();
            return(FigureSerializer.GetFiguresList(figures));
        }
        public void Save(List <Figure> figures)
        {
            string csvString = CsvSerializer.SerializeToCsv(FigureSerializer.GetMementoList(figures));

            File.WriteAllText(path, csvString);
        }
        public void Save(List <Figure> figures)
        {
            string jsonString = JsonConvert.SerializeObject(FigureSerializer.GetMementoList(figures));

            File.WriteAllText(path, jsonString);
        }