Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the Message class.
 /// </summary>
 /// <param name="to">The JID of the intended recipient.</param>
 /// <param name="body">The content of the message.</param>
 /// <param name="subject">The subject of the message.</param>
 /// <param name="thread">The conversation thread this message belongs to.</param>
 /// <param name="type">The type of the message. Can be one of the values from
 /// the MessagType enumeration.</param>
 /// <param name="language">The language of the XML character data of
 /// the stanza.</param>
 /// <exception cref="ArgumentNullException">The to parameter is null.</exception>
 /// <exception cref="ArgumentException">The body parameter is the empty string.</exception>
 public Message(Jid to, string body = null, string subject = null, string thread = null,
                MessageType type    = MessageType.Normal, CultureInfo language = null)
     : base(to, null, null, null, language)
 {
     to.ThrowIfNull("to");
     AlternateSubjects = new XmlDictionary(element, "subject", "xml:lang");
     AlternateBodies   = new XmlDictionary(element, "body", "xml:lang");
     Type      = type;
     Body      = SecurityElement.Escape(body);
     Subject   = SecurityElement.Escape(subject);
     Thread    = thread;
     Timestamp = DelayedDelivery.GetDelayedTimestampOrNow(element);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the Message class.
 /// </summary>
 /// <param name="to">The JID of the intended recipient.</param>
 /// <param name="bodies">A dictionary of message bodies. The dictionary
 /// keys denote the languages of the message bodies and must be valid
 /// ISO 2 letter language codes.</param>
 /// <param name="subjects">A dictionary of message subjects. The dictionary
 /// keys denote the languages of the message subjects and must be valid
 /// ISO 2 letter language codes.</param>
 /// <param name="thread">The conversation thread this message belongs to.</param>
 /// <param name="type">The type of the message. Can be one of the values from
 /// the MessagType enumeration.</param>
 /// <param name="language">The language of the XML character data of
 /// the stanza.</param>
 /// <exception cref="ArgumentNullException">The to parametr or the bodies
 /// parameter is null.</exception>
 public Message(Jid to, IDictionary <string, string> bodies,
                IDictionary <string, string> subjects = null, string thread = null,
                MessageType type = MessageType.Normal, CultureInfo language = null)
     : base(to, null, null, null, language)
 {
     to.ThrowIfNull("to");
     bodies.ThrowIfNull("bodies");
     AlternateSubjects = new XmlDictionary(element, "subject", "xml:lang");
     AlternateBodies   = new XmlDictionary(element, "body", "xml:lang");
     Type = type;
     foreach (var pair in bodies)
     {
         AlternateBodies.Add(pair.Key, pair.Value);
     }
     if (subjects != null)
     {
         foreach (var pair in subjects)
         {
             AlternateSubjects.Add(pair.Key, pair.Value);
         }
     }
     Thread    = thread;
     Timestamp = DelayedDelivery.GetDelayedTimestampOrNow(element);
 }