Exemple #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Kisiler.CollectionChanged += Kisiler_CollectionChanged;

            // Daha önceden veri kaydedilmiş ise..
            if (File.Exists(Application.StartupPath + "//data.xml"))
            {
                string xml = File.ReadAllText(Application.StartupPath + "//data.xml");

                Wissen.SC501.Common.Tools.XmlSerialization ser =
                    new Wissen.SC501.Common.Tools.XmlSerialization();

                ObservableCollection <Kisi> okunanData =
                    ser.FromXML <ObservableCollection <Kisi> >(xml);

                okunanData.ToList().ForEach(x => Kisiler.Add(x));
                return; // Dosyadan okuduysak örnek data oluşturmaya gerek yok.
            }


            // sample data..
            for (int i = 0; i < 20; i++)
            {
                Kisi kisi = new Kisi()
                {
                    ID    = i + 1,
                    Ad    = FakeData.NameData.GetFirstName(),
                    Soyad = FakeData.NameData.GetSurname(),
                    Tel   = FakeData.PhoneNumberData.GetPhoneNumber()
                };

                Kisiler.Add(kisi);
            }
        }
Exemple #2
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            Wissen.SC501.Common.Tools.XmlSerialization ser = new Wissen.SC501.Common.Tools.XmlSerialization();

            string xml = ser.ToXML(Kisiler);

            File.WriteAllText(Application.StartupPath + "//data.xml", xml);
        }