/// <summary> /// Reads Playing History of the neighbors from a file and loads into credibilityDataStore. /// Called at application initialization /// </summary> private void ReadCredibilityHistory() { credibilityDataStore = new List<PlayerHistoryRecord>(); StreamReader reader = null; if (File.Exists(credibilityFilePath) == false) return; reader = File.OpenText(credibilityFilePath); lock (credibilityDataStore) { while (reader.EndOfStream == false) { string playerID = reader.ReadLine().Trim(); PlayerHistoryRecord player = new PlayerHistoryRecord(playerID); int completedSessions = Int32.Parse(reader.ReadLine().Trim()); player.CompletedSessions = completedSessions; int totalSessions = Int32.Parse(reader.ReadLine().Trim()); player.TotalSessions = totalSessions; //It is important to read sessions line, even if it is blank. string[] sessions = reader.ReadLine().Trim().Split(new char[] { ' ' }); if (totalSessions != 0) { foreach (string session in sessions) { bool status = session.Equals("1") ? true : false; player.updateHistory(status); } } credibilityDataStore.Add(player); } } reader.Close(); }