示例#1
0
 public void AddMessage(MessageContainer message)
 {
     if (message.Room.Name.Equals(_room.Name))
     {
         _archive.Add(message);
     }
     else
     {
         throw new InvalidOperationException(string.Format("Invalid room message ({0}) insertion in this room {1}", message.Room.Name, _room.Name));
     }
 }
示例#2
0
 public bool LikeMessage(MessageContainer message)
 {
     foreach (var messageContainer in _archive)
     {
         if (messageContainer.Msg.Equals(message.Msg) && messageContainer.MsgId.Equals(message.MsgId))
         {
             messageContainer.AddLike();
             return(true);
         }
     }
     return(false);
 }
示例#3
0
        public bool RemoveMessage(MessageContainer message)
        {
            bool found = false;
            int  index;

            for (index = 0; index < _archive.Count; index++)
            {
                if (_archive[index].Msg.Equals(message.Msg) && _archive[index].MsgId.Equals(message.MsgId))
                {
                    found = true;
                    break;
                }
            }

            if (found)
            {
                _archive.RemoveAt(index);
                return(true);
            }
            return(false);
        }