예제 #1
0
파일: Controller.cs 프로젝트: ayodele1/EEJ
 public static void SaveCurrentState(string filename, AppState currentState)
 {
     DataContractSerializer dcs = new DataContractSerializer(typeof(AppState));
     if (filename != null)
     {
         using (FileStream fs = new FileStream(filename, FileMode.Create))
         {
             dcs.WriteObject(fs, currentState);
         }
     }
 }
예제 #2
0
파일: Controller.cs 프로젝트: ayodele1/EEJ
            public static AppState LoadState(string filename)
            {
                if (File.Exists(filename))
                {
                    AppState _loadedState = new AppState();
                    DataContractSerializer dcs = new DataContractSerializer(typeof(AppState));

                    using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        _loadedState = (AppState)dcs.ReadObject(fs);
                    }
                    return _loadedState;
                }
                return null;
            }
예제 #3
0
파일: Controller.cs 프로젝트: ayodele1/EEJ
 private static void GetLoadedState(AppState SavedState)
 {
     QAData.QuestCount = SavedState.QuestionNo;
     QAData.ResourceArray = SavedState.CurrentResources;
     QAData.UserAnswers = SavedState.CurrentAnswers;
     wrongAnswersIndices = SavedState.CurrentWrongAnswers;
     wrongAnswersIndex = SavedState.WrongAnswerIndex;
     exerciseCounter = SavedState.CurrentExerciseIndex;
 }