using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization; using MessageBoard.Properties; namespace MessageBoard { /// <summary> /// Represents a message in the message board /// </summary> [DataContract] public class Message { public Message() { } public Message(int id, string subject, string text, string postedBy, string postedById, DateTime postedDate) { this.Id = id; this.Subject = subject; this.Text = text; this.PostedBy = postedBy; this.PostedById = postedById; this.DatePosted = postedDate; this.Frozen = true; } private int _id; [DataMember] public int Id { get { return _id; } set { CheckImmutable(); _id = value; } } private string _subject; [DataMember] public string Subject { get { return _subject; } set { CheckImmutable(); _subject = value; } } private string _text; [DataMember] public string Text { get { return _text; } set { CheckImmutable(); _text = value; } } private string _postedBy; [DataMember] public string PostedBy { get { return _postedBy; } set { CheckImmutable(); _postedBy = value; } } private string _postedById; [DataMember] public string PostedById { get { return _postedById; } set { CheckImmutable(); _postedById = value; } } private DateTime _datePosted; [DataMember] public DateTime DatePosted { get { return _datePosted; } set { CheckImmutable(); _datePosted = value; } } private void CheckImmutable() { if (Frozen) throw new InvalidOperationException(Resources.ObjectFrozen); } public bool Frozen { get; private set; } public Message Freeze() { this.Frozen = true; return this; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)