Exemplo n.º 1
0
        public static Lotto LoadData(string filePath)
        {
            Stream stream = null;
            Lotto  lotto  = null;

            try
            {
                stream = File.OpenRead(filePath);
                BinaryFormatter serializer = new BinaryFormatter();
                lotto = (Lotto)serializer.Deserialize(stream);
            }
            catch { }
            finally
            {
                stream.Dispose();
            }
            return(lotto);
        }
Exemplo n.º 2
0
        public static bool SaveData(Lotto _lotto, string fileName)
        {
            var    res    = true;
            Stream stream = null;

            try
            {
                stream = File.Create(fileName);
                var serializer = new BinaryFormatter();
                serializer.Serialize(stream, _lotto);
            }
            catch
            {
                res = false;
            }
            finally
            {
                stream?.Dispose();
            }
            return(res);
        }
Exemplo n.º 3
0
 static void LoadData(Lotto _lotto)
 {
     _lotto.AddDraw(new Draw(1, new DateTime(2017, 10, 13, 23, 0, 0),
                             new int[] { 21, 15, 12, 3, 44, 2 }, 25279082, true));
 }