コード例 #1
0
        private void bSave_Click(object sender, RoutedEventArgs e)
        {
            UsersList saveList = new UsersList();

            saveList.users = new List <User>();
            foreach (var user in xList)
            {
                saveList.users.Add(user);
            }
            XmlSerializer ser = new XmlSerializer(typeof(UsersList));

            using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
            {
                ser.Serialize(fs, saveList);
            }
            MessageBox.Show("Plik został zapisany na pulpicie");
        }
コード例 #2
0
        void showDataInDataGrid()
        {
            deserializedList       = new UsersList();
            deserializedList.users = new List <User>();
            XmlSerializer ser = new XmlSerializer(typeof(UsersList));

            using (FileStream fs = new FileStream(path, FileMode.Open))
            {
                deserializedList = (UsersList)ser.Deserialize(fs);
                xList            = new ObservableCollection <User>();
                foreach (var user in deserializedList.users)
                {
                    xList.Add(user);
                }
            }
            // xListTemp = new ObservableCollection<User>();
            //xListTemp = xList;
            dataGrid.ItemsSource = xList;
            // dataGrid.ItemsSource = deserializedList.users;
            //dataGrid.
        }
コード例 #3
0
 void addUsersToXML(UsersList ul)
 {
     ul.users.Add(new User("tomasz", "ladowski", "a", "9", "", "43-300", "Poznan", "666", new DateTime(1994, 4, 5)));
     ul.users.Add(new User("mateusz", "kasprzyk", "a", "9", "", "43-300", "Poznan", "666", new DateTime(1992, 3, 5)));
     ul.users.Add(new User("andrzej", "ladowski", "a", "9", "", "43-300", "Poznan", "666", new DateTime(1994, 3, 5)));
 }