Example #1
0
        public static bool TryParse(string message, out MessagePayload payload)
        {
            payload = default;

            if (string.IsNullOrWhiteSpace(message))
            {
                return(false);
            }

            var parts = message.Split(Separators, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length == 0)
            {
                return(false);
            }

            var text = parts[0].Trim();

            if (parts.Length == 1)
            {
                payload = new MessagePayload(text, DateTimeOffset.UtcNow);
            }

            if (parts.Length == 1 && text.ToLower() == "info")
            {
                text    = "info";
                payload = new MessagePayload(text, DateTimeOffset.UtcNow);
            }

            if (parts.Length > 1 && TryParseDateTime(parts[1], out var datetime))
            {
                payload = new MessagePayload(text, datetime);
            }

            return(payload != default);
        }
Example #2
0
 public MessageReceivedEventArgs(MessagePayload message, string contactId)
 {
     Message   = message;
     ContactId = contactId;
 }