using System; using System.Collections.Generic; using System.Text; namespace ScrewTurn.Wiki.PluginFramework { /// /// Represents a Page Discussion Message. /// public class Message { /// /// The Message ID. /// protected int id; /// /// The Username. /// protected string username; /// /// The Subject. /// protected string subject; /// /// The Date/Time. /// protected DateTime dateTime; /// /// The Body. /// protected string body; /// /// The Replies. /// protected Message[] replies = new Message[0]; /// /// Initializes a new instance of the Message class. /// /// The ID of the Message. /// The Username of the User. /// The Subject of the Message. /// The Date/Time of the Message. /// The body of the Message. public Message(int id, string username, string subject, DateTime dateTime, string body) { this.id = id; this.username = username; this.subject = subject; this.dateTime = dateTime; this.body = body; } /// /// Gets or sets the Message ID. /// public int ID { get { return id; } set { id = value; } } /// /// Gets or sets the Username. /// public string Username { get { return username; } set { username = value; } } /// /// Gets or sets the Subject. /// public string Subject { get { return subject; } set { subject = value; } } /// /// Gets or sets the Date/Time. /// public DateTime DateTime { get { return dateTime; } set { dateTime = value; } } /// /// Gets or sets the Body. /// public string Body { get { return body; } set { body = value; } } /// /// Gets or sets the Replies. /// public Message[] Replies { get { return replies; } set { replies = value; } } } /// /// Compares two Message object using their Date/Time as parameter. /// public class MessageDateTimeComparer : IComparer { bool reverse = false; /// /// Initializes a new instance of the MessageDateTimeComparer class. /// /// True to compare in reverse order (bigger to smaller). public MessageDateTimeComparer(bool reverse) { this.reverse = reverse; } /// /// Compares two Message objects. /// /// The first object. /// The second object. /// The result of the comparison (1, 0 or -1). public int Compare(Message x, Message y) { if(!reverse) return x.DateTime.CompareTo(y.DateTime); else return y.DateTime.CompareTo(x.DateTime); } } }