/// <summary>
        /// Removes the engagements of the given conversation owners.
        /// </summary>
        /// <param name="conversationOwnerParties">The conversation owners whose engagements to remove.</param>
        /// <returns>The number of engagements removed.</returns>
        protected virtual IList <MessageRouterResult> RemoveEngagements(IList <Party> conversationOwnerParties)
        {
            IList <MessageRouterResult> messageRouterResults = new List <MessageRouterResult>();

            foreach (Party conversationOwnerParty in conversationOwnerParties)
            {
                EngagedParties.TryGetValue(conversationOwnerParty, out Party conversationClientParty);

                if (EngagedParties.Remove(conversationOwnerParty))
                {
                    if (conversationOwnerParty is EngageableParty)
                    {
                        (conversationOwnerParty as EngageableParty).ResetEngagementStartedTime();
                    }

                    if (conversationClientParty is EngageableParty)
                    {
                        (conversationClientParty as EngageableParty).ResetEngagementStartedTime();
                    }

                    messageRouterResults.Add(new MessageRouterResult()
                    {
                        Type = MessageRouterResultType.EngagementRemoved,
                        ConversationOwnerParty  = conversationOwnerParty,
                        ConversationClientParty = conversationClientParty
                    });
                }
            }

            return(messageRouterResults);
        }
        public virtual Party GetEngagedCounterpart(Party partyWhoseCounterpartToFind)
        {
            Party counterparty = null;

            if (IsEngaged(partyWhoseCounterpartToFind, EngagementProfile.Client))
            {
                for (int i = 0; i < EngagedParties.Count; ++i)
                {
                    if (EngagedParties.Values.ElementAt(i).Equals(partyWhoseCounterpartToFind))
                    {
                        counterparty = EngagedParties.Keys.ElementAt(i);
                        break;
                    }
                }
            }
            else if (IsEngaged(partyWhoseCounterpartToFind, EngagementProfile.Owner))
            {
                EngagedParties.TryGetValue(partyWhoseCounterpartToFind, out counterparty);
            }

            return(counterparty);
        }
        /// <summary>
        /// Removes the engagements of the given conversation owners.
        /// </summary>
        /// <param name="conversationOwnerParties">The conversation owners whose engagements to remove.</param>
        /// <returns>The number of engagements removed.</returns>
        protected virtual IList <MessageRouterResult> RemoveEngagements(IList <Party> conversationOwnerParties)
        {
            IList <MessageRouterResult> messageRouterResults = new List <MessageRouterResult>();

            foreach (Party conversationOwnerParty in conversationOwnerParties)
            {
                Party conversationClientParty = null;
                EngagedParties.TryGetValue(conversationOwnerParty, out conversationClientParty);

                if (EngagedParties.Remove(conversationOwnerParty))
                {
                    messageRouterResults.Add(new MessageRouterResult()
                    {
                        Type = MessageRouterResultType.EngagementRemoved,
                        ConversationOwnerParty  = conversationOwnerParty,
                        ConversationClientParty = conversationClientParty
                    });
                }
            }

            return(messageRouterResults);
        }