コード例 #1
0
        public void ClearMessageEntities(Guid messageId)
        {
            CrmMessageEntity[] entityList;
            if (messageId == Guid.Empty)
            {
                //Copy the list of entities. Can't use the enumerator because we are changing the underlying data
                entityList = new CrmMessageEntity[m_messageEntityList.Count];
                m_messageEntityList.Values.CopyTo(entityList, 0);
            }
            else if (m_messageList.ContainsKey(messageId))
            {
                //Copy the list of entities. Can't use the enumerator because we are changing the underlying data
                entityList = m_messageList[messageId].MessageEntities.ToArray();
            }
            else
            {
                throw new ArgumentException("Invalid Entity Id", "messageId");
            }

            //Loop through the entity id's
            foreach (CrmMessageEntity message in entityList)
            {
                RemoveMessageEntity(message.MessageId, message.MessageEntityId);
            }
        }
コード例 #2
0
        public void AddMessageEntity(CrmMessageEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            m_filterList.Add(entity.MessageEntityId, entity);

            if (Organization != null)
            {
                Organization.AddMessageEntity(this, entity);
            }
        }
コード例 #3
0
        public void AddMessageEntity(CrmMessage message, CrmMessageEntity entity)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }
            else if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            else if (!message.MessageEntities.ContainsKey(entity.MessageEntityId))
            {
                message.AddMessageEntity(entity);
                return;
            }
            else
            {
                ValidateEntity(entity);
            }

            m_messageEntityList.Add(entity.EntityId, entity);
        }
コード例 #4
0
 private void ValidateEntity(CrmMessageEntity messageEntity)
 {
     if (messageEntity == null)
     {
         throw new ArgumentNullException();
     }
     else if (m_messageEntityList.ContainsKey(messageEntity.MessageEntityId))
     {
         throw new ArgumentException("MessageEntity is already in the list");
     }
     else if (messageEntity.Organization != this)
     {
         throw new ArgumentException("Organization must match");
     }
     else if (messageEntity.MessageId == Guid.Empty)
     {
         throw new ArgumentException("MessageId must be set to valid Guid");
     }
     else if (messageEntity.MessageEntityId == Guid.Empty)
     {
         throw new ArgumentException("MessageEntityId must be set to valid Guid");
     }
 }