public void RemoveExamInfo(ExamFileInfo info) { ExamFileCatalogueInfo examCatalogue; using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("examCatalogue.json", FileMode.Open, _isolatedStorageFile)) { using (StreamReader reader = new StreamReader(isoStream)) examCatalogue = JsonConvert.DeserializeObject <ExamFileCatalogueInfo>(reader.ReadToEnd()); } int index = -1; for (int i = 0; i < examCatalogue.ExamFileInfos.Count; i++) { if (examCatalogue.ExamFileInfos[0].Id.Equals(info.Id)) { index = i; break; } } if (index > -1) { examCatalogue.ExamFileInfos.RemoveAt(index); } _isolatedStorageFile.DeleteFile("examCatalogue.json"); using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("examCatalogue.json", FileMode.CreateNew, _isolatedStorageFile)) { using (StreamWriter writer = new StreamWriter(isoStream)) writer.Write(JsonConvert.SerializeObject(examCatalogue)); } }
public Exam LoadExam(ExamFileInfo examInfo) { if (File.Exists(examInfo.Path)) { return(JsonConvert.DeserializeObject <Exam>(File.ReadAllText(examInfo.Path))); } return(null); }
public void BeginExam(ExamFileInfo examInfo) { ExamSession session = _uiManager.ShowExamConfigurationView(examInfo); if (session != null) { BeginExamSession(session); } OnExamCompleted?.Invoke(null, session == null ? ExamOutcome.NotStarted : ExamOutcome.Completed); }
public ExamSession ShowExamConfigurationView(ExamFileInfo examInfo) { Exam exam = _storageManager.LoadExam(examInfo); _examConfigurationView.ShowDialog(Application.OpenForms[0], exam); if (_examConfigurationView.CustomCloseReason == CustomCloseReason.ok) { return(_examConfigurationView.ExamSession); } return(null); }