예제 #1
0
 private void CheckDataCorrectness()
 {
     if (schoolData.classes == null || schoolData.rooms == null || schoolData.teachers == null || schoolData.groups == null || schoolData.activities == null)
     {
         schoolData = new SchoolData();
     }
 }
예제 #2
0
        public void DeserializeData()
        {
            if (File.Exists(jsonFile))
            {
                var jsonData = File.ReadAllText(jsonFile);
                if (String.IsNullOrEmpty(jsonData))
                {
                    schoolData = new SchoolData();
                    return;
                }

                try
                {
                    schoolData = JsonSerializer.Deserialize <SchoolData>(jsonData);
                    CheckDataCorrectness();
                }
                catch (JsonException)
                {
                    schoolData = new SchoolData();
                }
            }
            else
            {
                File.Create(jsonFile);
                schoolData = new SchoolData();;
                SerializeData();
            }
        }