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

            File.WriteAllText(path, yamlString);
        }
예제 #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();
        }
예제 #3
0
 public void Save(List <Figure> figures)
 {
     using (Stream stream = File.Open(path, FileMode.Create))
     {
         BinaryFormatter bformatter = new BinaryFormatter();
         bformatter.Serialize(stream, FigureSerializer.GetMementoList(figures));
     }
 }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #9
0
        public void Save(List <Figure> figures)
        {
            string csvString = CsvSerializer.SerializeToCsv(FigureSerializer.GetMementoList(figures));

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

            File.WriteAllText(path, jsonString);
        }