Ejemplo n.º 1
0
        static public void RewriteCusomers(CustomerMemmorry p)
        {
            FileStream DummyFileStream = null;

            try
            {
                CustomerMemmorry t             = p.CustomersNodeAccess;
                FileInfo         DummyFileInfo = new FileInfo(SCustomer);
                DummyFileInfo.Delete();
                DummyFileStream = new FileStream(SCustomer, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                BinaryFormatter Formatters = new BinaryFormatter();
                DummyFileStream.Seek(0, SeekOrigin.Begin);
                while (t != null)
                {
                    Formatters.Serialize(DummyFileStream, t.CustomersCurrentAccess);
                    t = t.CustomersNextAccess;
                }
                DummyFileStream.Close();
            }
            catch (NullReferenceException o)
            {
                Console.WriteLine(o.Message.ToString());
            }
            catch (IOException o)
            {
                Console.WriteLine(o.Message.ToString());
            }
        }
Ejemplo n.º 2
0
        public void AddObject(CustomerMemmorry p)
        {
            CustomerMemmorry t = new CustomerMemmorry();

            t = p.CustomersNodeAccess;
            while (t.CustomersNextAccess != null)
            {
                t = t.CustomersNextAccess;
            }
            if (t.CustomersCurrentAccess == null)
            {
                t.CustomersCurrentAccess = p.CustomersCurrentAccess;
            }
            else
            {
                t.CustomersNextAccess = p;
            }
        }
Ejemplo n.º 3
0
        public void DeleteObject(CustomerMemmorry p)
        {
            CustomerMemmorry t = new CustomerMemmorry();

            t = Node;
            if ((t.CustomersCurrentAccess.CustomersName) != (p.CustomersCurrentAccess.CustomersName))
            {
                if (t != null)
                {
                    while ((t.CustomersNextAccess.CustomersCurrentAccess.CustomersName) != (p.CustomersCurrentAccess.CustomersName))
                    {
                        if (t.CustomersNextAccess != null)
                        {
                            t = t.CustomersNextAccess;
                        }
                        else
                        if ((t.CustomersCurrentAccess.CustomersName) != (p.CustomersCurrentAccess.CustomersName))
                        {
                            t = null;
                            break;
                        }
                    }
                }
                if (t != null)
                {
                    if (t.CustomersNextAccess != null)
                    {
                        t.CustomersNextAccess = t.CustomersNextAccess.CustomersNextAccess;
                    }

                    else
                    {
                        t.CustomersNextAccess = null;
                    }
                }
            }
            else
            {
                t    = t.CustomersNextAccess;
                Node = t;
            }
        }
Ejemplo n.º 4
0
 public void Load()
 {
     if (Node == null)
     {
         Node = new CustomerMemmorry();
     }
     Node.CustomersNextAccess    = null;
     Node.CustomersCurrentAccess = null;
     try
     {
         FileStream                 DummyFileStream = new FileStream(S, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
         BinaryFormatter            Formatters      = new BinaryFormatter();
         RefrigtzW.Customers        Dummy           = new Customers();
         RefrigtzW.CustomerMemmorry Last            = null;
         Console.WriteLine("Loading...");
         DummyFileStream.Seek(0, SeekOrigin.Begin);
         while (DummyFileStream.Position < DummyFileStream.Length)
         {
             Dummy = (Customers)Formatters.Deserialize(DummyFileStream);
             if (Node.Current == null)
             {
                 Node.Current = Dummy;
             }
             else
             {
                 Last = Node;
                 while (Last.Next != null)
                 {
                     Last = Last.Next;
                 }
                 CustomerMemmorry New = new CustomerMemmorry();
                 New.Current = Dummy;
                 Last.CustomersNextAccess = New;
             }
         }
         DummyFileStream.Flush();
         DummyFileStream.Close();
     }
     catch (IOException t) { Console.WriteLine(t.Message.ToString()); }
 }