//public static void GetCurrentStateVariables(QAMgr QABot) //{ // AppStateInfo asi = new AppStateInfo(QABot.QuestionCount,QABot.ExerciseCount); //} public static void SaveCurrrentStateVariables(AppStateInfo asi) { DataContractSerializer dcs = new DataContractSerializer(typeof(AppStateInfo)); using (FileStream fs = new FileStream(_appDataFileName, FileMode.Create)) { dcs.WriteObject(fs, asi); } }
private void InitializeLoadedState(AppStateInfo loadedState) { if (string.Compare(loadedState.CurrentState, "RetakeState") == 0) { _currentAppState = new RetakeState(this); QABot.FailedQuestions = loadedState.FailedQuestionsList; } else if (string.Compare(loadedState.CurrentState, "NormalState") == 0) { _currentAppState = new NormalState(this); } QABot.ExerciseCount = loadedState.CurrentExerciseNo; QABot.QuestionCount = loadedState.CurrentQuestionNo; QABot.SavedAnswers = loadedState.SavedAnswers; _currentAppState.InitializeNew(); }