コード例 #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;
 }