Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
/ Sharp.Xmpp Public archive
forked from pgstath/Sharp.Xmpp

Commit

Permalink
Added a new constructor to IM.Message which allows to create a message
Browse files Browse the repository at this point in the history
from an XmlElement (h/t pgstath#14)
  • Loading branch information
stevenlivz authored and jpenny1993 committed Aug 31, 2021
1 parent e89b670 commit 27207e7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Im/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,20 @@ public Message(Jid to, String body, string othertagname, IDictionary<string, str
Thread = thread;
}

/// <summary>
/// Initializes a new instance of the Message class from the specified
/// instance.
/// </summary>
/// <param name="data">The message element</param>
/// <exception cref="ArgumentNullException">The Data parameter is null.</exception>
public Message(XmlElement data)
{

Data.ThrowIfNull("data");
type = ParseType(data.GetAttribute("type"));
element = data;
}

/// <summary>
/// Initializes a new instance of the Message class from the specified
/// instance.
Expand Down
10 changes: 10 additions & 0 deletions Im/MessageEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,15 @@ public MessageEventArgs(Jid jid, Message message, Boolean carbonCopy = false)
Message = message;
CarbonCopy = carbonCopy;
}

/// <summary>
/// Initializes a new instance of the MessageEventArgs class for bodyless messages.
/// </summary>
/// <exception cref="ArgumentNullException">The message parameter is null.</exception>
public MessageEventArgs(Message message)
{
message.ThrowIfNull("message");
Message = message;
}
}
}

0 comments on commit 27207e7

Please sign in to comment.