From 8f9e1b14292d90acc42e51062864a75f0f23f6c8 Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Wed, 24 Aug 2022 09:48:56 +0200 Subject: [PATCH] I have no idea anymore why I needed this function --- PlayerJournal.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/PlayerJournal.cs b/PlayerJournal.cs index 7f922c3..4cab75a 100644 --- a/PlayerJournal.cs +++ b/PlayerJournal.cs @@ -62,5 +62,28 @@ namespace EDJournal { journalfiles.Sort(); } + + public Entry FindMostRecent(string entry) { + var entries = journalfiles + .OrderByDescending(x => x.DateTime) + .ToArray() + ; + + if (entries == null || entries.Length == 0) { + return null; + } + + foreach(JournalFile file in entries) { + Entry found = file.Entries + .OrderByDescending(x => x.Timestamp) + .First(x => x.Event == entry) + ; + if (found != null) { + return found; + } + } + + return null; + } } }