Skip to content

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 committed May 9, 2017
1 parent 077959d commit b2936f1
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 @@ -275,6 +275,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 @@ -37,5 +37,15 @@ public MessageEventArgs(Jid jid, Message message)
Jid = jid;
Message = message;
}

/// <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 b2936f1

Please sign in to comment.