private static bool FindMessage(Message.ID id, out Message.Data result, bool pop) { Incoming.Message cache = s_Messages.Find(m => id == m.GetID(), pop: pop); if (null == cache) { result = default; return(false); } result = new Message.Data { Channel = Channel.Deserialized(cache.GetChannel()), Author = new User(cache.GetSender()?.GetName() ?? ""), Contents = cache.GetContent()?.GetText()?.GetBody() ?? "" }; return(true); }
/// <summary> /// Remove the message from the log, returning whether it was found, passing its data via out if so /// </summary> public static bool TryRemoveFromLog(Message.ID id, out Message.Data result) => FindMessage(id, out result, pop: true);
/// <summary> /// Read the message from the log, returning whether the read was successful, passing the data via out if so /// </summary> public static bool TryReadFromLog(Message.ID id, out Message.Data result) => FindMessage(id, out result, pop: false);