コード例 #1
0
        public static Solution Deserialize(string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Solution));

            using (XmlReader Reader = XmlReader.Create(path))
            {
                Solution solution = (Solution)serializer.Deserialize(Reader);

                HistoryCollection histories = HistoryCollection.Deserialize();
                if (histories.Contains(solution.Name))
                {
                    histories[solution.Name].Extension = solution.Extension;
                    histories[solution.Name].Path      = solution.Path;
                    histories[solution.Name].OpenTime  = DateTime.Now;
                }
                else
                {
                    histories.Add(new History()
                    {
                        Name = solution.Name, Extension = solution.Extension, Path = solution.Path, OpenTime = DateTime.Now
                    });
                }
                histories.Serialize();

                return(solution);
            }
        }
コード例 #2
0
        public void Serialize()
        {
            if (!Directory.Exists(Path))
            {
                Directory.CreateDirectory(Path);
            }
            XmlSerializer serializer = new XmlSerializer(typeof(Solution));

            using (XmlWriter xmlWriter = XmlWriter.Create(Path + @"\" + Name + ".gse"))
            {
                serializer.Serialize(xmlWriter, this);
            }

            HistoryCollection histories = HistoryCollection.Deserialize();

            if (histories.Contains(Name))
            {
                histories[Name].Extension = Extension;
                histories[Name].Path      = Path;
                histories[Name].SaveTime  = DateTime.Now;
            }
            else
            {
                histories.Add(new History()
                {
                    Name = Name, Extension = Extension, Path = Path, SaveTime = DateTime.Now
                });
            }
            histories.Serialize();
        }