예제 #1
0
파일: user.cs 프로젝트: groshik/curs
        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;
        }
예제 #2
0
파일: student.cs 프로젝트: groshik/curs
        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;
        }