private ChatType GetNextChat() { ChatType result = null; if (CurrentArchive == null && Months != null && CurrentMonth < Months.Count) { CurrentArchive = GetArchive(); } else if (CurrentArchive == null && Months != null && CurrentMonth >= Months.Count) { if (GetNextYear()) { return(GetNextChat()); } } if (CurrentArchive != null && CurrentReader == null) { CurrentReader = GetNextReader(); if (CurrentReader == null) { CurrentMonth++; CurrentArchive = null; return(GetNextChat()); } } if (CurrentReader != null) { result = END_RESULT; string nextLine; while (result == END_RESULT && (nextLine = CurrentReader.ReadLine()) != null) { var chatType = ChatLineParser.ParseChatType(nextLine); if (chatType != null && chatType.Line.Length > 0) { // fix % chars chatType.Line = chatType.Line.Replace("&PCT;", "%"); } result = CurrentChatFilter.PassFilter(chatType) ? chatType : result; } if (result == END_RESULT) { CurrentReader.Close(); CurrentReader = null; return(GetNextChat()); } } return(result); }