Example #1
0
 public Customer(string name, string email, int phone, bool staff)
 {
     SingletonDataCustomer.getInstance();
     this.Id    = SingletonDataCustomer.NextId;
     this.Name  = name;
     this.Phone = phone;
     this.Staff = staff;
     this.Email = email;
 }
Example #2
0
        public void Read()
        {
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream("Objects.bin", FileMode.Open, FileAccess.Read,
                                                  FileShare.Read);

            _controller.custList = (List <Customer>)formatter.Deserialize(stream);
            SingletonDataCustomer.setInstance((SingletonDataCustomer)formatter.Deserialize(stream));
            stream.Close();
        }
Example #3
0
        /// <summary>
        /// Writes Customer data to binary file, persists nextID
        /// </summary>
        public void WriteBinaryData()
        {
            //create a formatting object
            IFormatter formatter = new BinaryFormatter();

            //Create a new IO stream to write to the file Objects.bin
            Stream stream = new FileStream("objects.bin", FileMode.Create,
                                           FileAccess.Write, FileShare.None);

            //use the formatter to serialize the collection and send it to the filestream
            formatter.Serialize(stream, custList);
            formatter.Serialize(stream, SingletonDataCustomer.getInstance());

            //close the file
            stream.Close();
        }