static string FormatSource(LogEntry logentry) { if (string.IsNullOrEmpty(logentry.Source)) return string.Empty; var result = " <" + logentry.Source + ">"; if ( logentry.PmConversationRecipient != CharacterName.Empty && !logentry.Source.Equals(logentry.PmConversationRecipient.ToString(), StringComparison.InvariantCultureIgnoreCase)) { result += " to <" + logentry.PmConversationRecipient + ">"; } return result; }
/// <summary> /// Converts Log Entry into universal string representation resembling original log entry + date /// </summary> /// <returns></returns> public string RestoreLogEntry(LogEntry logentry) { var stamp = logentry.Timestamp; return string.Format("{0}{1} {2}", stamp.ToString("[yyyy-MM-dd] [HH:mm:ss]", CultureInfo.InvariantCulture), FormatSource(logentry), logentry.Content); }