예제 #1
0
        public YearTop Copy()
        {
            YearTop         retYear      = null;
            BinaryFormatter serializer   = new BinaryFormatter();
            BinaryFormatter deserializer = new BinaryFormatter();

            using (MemoryStream stream = new MemoryStream())
            {
                serializer.Serialize(stream, this);
                stream.Position = 0;
                retYear         = (YearTop)deserializer.Deserialize(stream);
            }

            return(retYear);
        }
예제 #2
0
        static public YearTop LoadFromFile(string filepath)
        {
            YearTop jsonYear = null;

            if (File.Exists(filepath))
            {
                Console.WriteLine("Reading saved file");
                Stream          openFileStream = File.OpenRead(filepath);
                BinaryFormatter deserializer   = new BinaryFormatter();
                jsonYear = (YearTop)deserializer.Deserialize(openFileStream);
                jsonYear.TimeLastLoaded = DateTime.Now;
                openFileStream.Close();
            }
            return(jsonYear);
        }