static public void Load() { User selUser = Program.SelectUser; Program.SelectUser = null; string path = Path.Combine(Directory.GetCurrentDirectory(), "data\\users.hav"); if (File.Exists(path)) { string JSONString; FileRead JSONRead = new FileRead(); JSONString = JSONRead.GetJSONString(path); UsertCollection usertCollection = JsonConvert.DeserializeObject <UsertCollection>(JSONString); Items = usertCollection.Users; Items.ForEach(user => { user.ChangeDataEvent += () => { ChangeDataInListEvent?.Invoke(); }; }); } else { Save(); Load(); } if (selUser != null) { selUser = Users.GetUser(selUser.Login); } Program.SelectUser = selUser; }
static public void Load() { User selUser = Program.SelectUser; Program.SelectUser = null; string path = Path.Combine(Directory.GetCurrentDirectory(), "data\\students.hav"); if (File.Exists(path)) { string JSONString; FileRead JSONRead = new FileRead(); JSONString = JSONRead.GetJSONString(path); StudentCollection studentCollection = JsonConvert.DeserializeObject <StudentCollection>(JSONString); Items = studentCollection.Students; Items.ForEach(student => { student.ChangeDataEvent += () => { ChangeDataInListEvent?.Invoke(); }; }); } else { Save(); Load(); } Program.SelectUser = selUser; }