internal override void RenderContents(TextWriter writer, UserContext userContext, RecipientWellType type, RecipientWellNode.RenderFlags flags, RenderRecipientWellNode wellNode)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (!this.HasRecipients(type))
            {
                return;
            }
            IEnumerator <Participant> recipientsCollection = this.GetRecipientsCollection(type);

            RecipientWellNode.RenderFlags renderFlags = flags & ~RecipientWellNode.RenderFlags.RenderCommas;
            bool flag  = true;
            bool flag2 = userContext.IsInstantMessageEnabled();

            Result <ADRawEntry>[] array = null;
            int num = 0;

            while (recipientsCollection.MoveNext())
            {
                Participant participant       = recipientsCollection.Current;
                string      smtpAddress       = null;
                string      alias             = null;
                string      text              = null;
                int         num2              = 0;
                ADObjectId  adObjectId        = null;
                string      mobilePhoneNumber = null;
                if (participant.RoutingType == "EX" && !string.IsNullOrEmpty(participant.EmailAddress))
                {
                    bool flag3 = (flags & RecipientWellNode.RenderFlags.ReadOnly) != RecipientWellNode.RenderFlags.None;
                    if (flag3)
                    {
                        alias = Utilities.GetParticipantProperty <string>(participant, ParticipantSchema.Alias, null);
                    }
                    bool participantProperty = Utilities.GetParticipantProperty <bool>(participant, ParticipantSchema.IsDistributionList, false);
                    if (participantProperty)
                    {
                        num2 |= 1;
                    }
                    bool participantProperty2 = Utilities.GetParticipantProperty <bool>(participant, ParticipantSchema.IsRoom, false);
                    if (participantProperty2)
                    {
                        num2 |= 2;
                    }
                    smtpAddress = Utilities.GetParticipantProperty <string>(participant, ParticipantSchema.SmtpAddress, null);
                    if (flag2 && !participantProperty && !participantProperty2)
                    {
                        text = Utilities.GetParticipantProperty <string>(participant, ParticipantSchema.SipUri, null);
                        if (text == null || text.Trim().Length == 0)
                        {
                            if (array == null)
                            {
                                array = AdRecipientBatchQuery.FindAdResultsByLegacyExchangeDNs(this.GetRecipientsCollection(type), userContext);
                            }
                            ADRawEntry data = array[num].Data;
                            if (data != null)
                            {
                                adObjectId = (ADObjectId)data[ADObjectSchema.Id];
                                text       = InstantMessageUtilities.GetSipUri((ProxyAddressCollection)data[ADRecipientSchema.EmailAddresses]);
                                if (text != null && text.Trim().Length == 0)
                                {
                                    text = null;
                                }
                            }
                        }
                    }
                    if (userContext.IsSmsEnabled)
                    {
                        if (array == null)
                        {
                            array = AdRecipientBatchQuery.FindAdResultsByLegacyExchangeDNs(this.GetRecipientsCollection(type), userContext);
                        }
                        ADRawEntry data2 = array[num].Data;
                        if (data2 != null)
                        {
                            mobilePhoneNumber = (string)data2[ADOrgPersonSchema.MobilePhone];
                        }
                    }
                    num++;
                }
                else if (participant.RoutingType == "SMTP")
                {
                    smtpAddress = participant.EmailAddress;
                    if (flag2)
                    {
                        text = participant.EmailAddress;
                    }
                }
                else if (string.CompareOrdinal(participant.RoutingType, "MAPIPDL") == 0)
                {
                    num2 |= 1;
                }
                StoreObjectId          storeObjectId          = null;
                EmailAddressIndex      emailAddressIndex      = EmailAddressIndex.None;
                StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin;
                if (storeParticipantOrigin != null && storeParticipantOrigin.OriginItemId != null)
                {
                    storeObjectId     = storeParticipantOrigin.OriginItemId;
                    emailAddressIndex = storeParticipantOrigin.EmailAddressIndex;
                }
                if (wellNode(writer, userContext, participant.DisplayName, smtpAddress, participant.EmailAddress, participant.RoutingType, alias, RecipientAddress.ToAddressOrigin(participant), num2, storeObjectId, emailAddressIndex, adObjectId, renderFlags, text, mobilePhoneNumber) && flag)
                {
                    flag = false;
                    if ((flags & RecipientWellNode.RenderFlags.RenderCommas) != RecipientWellNode.RenderFlags.None)
                    {
                        renderFlags |= RecipientWellNode.RenderFlags.RenderCommas;
                    }
                }
            }
        }
        public void ExpandDistributionList()
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "RecipientWellEventHandler.ExpandDistributionList");
            RecipientInfo[]    array = (RecipientInfo[])base.GetParameter("Recips");
            List <Participant> list  = new List <Participant>();

            foreach (RecipientInfo recipientInfo in array)
            {
                if (recipientInfo.StoreObjectId == null || !Utilities.IsMapiPDL(recipientInfo.RoutingType))
                {
                    throw new OwaEventHandlerException("The requested recipient is not personal distribution list");
                }
                list.AddRange(DistributionList.ExpandDeep(base.UserContext.MailboxSession, recipientInfo.StoreObjectId));
            }
            using (List <Participant> .Enumerator enumerator = list.GetEnumerator())
            {
                AdRecipientBatchQuery adRecipientBatchQuery = new AdRecipientBatchQuery(enumerator, base.UserContext);
                bool flag = false;
                foreach (Participant participant in list)
                {
                    string            smtpAddress       = null;
                    string            sipUri            = null;
                    ADObjectId        adObjectId        = null;
                    StoreObjectId     storeObjectId     = null;
                    EmailAddressIndex emailAddressIndex = EmailAddressIndex.None;
                    string            mobilePhoneNumber = null;
                    if (participant.RoutingType == "EX")
                    {
                        ADRecipient adRecipient = adRecipientBatchQuery.GetAdRecipient(participant.EmailAddress);
                        if (adRecipient != null)
                        {
                            smtpAddress       = adRecipient.PrimarySmtpAddress.ToString();
                            adObjectId        = adRecipient.Id;
                            sipUri            = InstantMessageUtilities.GetSipUri((ProxyAddressCollection)adRecipient[ADRecipientSchema.EmailAddresses]);
                            mobilePhoneNumber = Utilities.NormalizePhoneNumber((string)adRecipient[ADOrgPersonSchema.MobilePhone]);
                        }
                    }
                    else
                    {
                        smtpAddress = participant.EmailAddress;
                        sipUri      = participant.EmailAddress;
                    }
                    RecipientAddress.RecipientAddressFlags recipientAddressFlags = RecipientAddress.RecipientAddressFlags.None;
                    if (participant.GetValueOrDefault <bool>(ParticipantSchema.IsDistributionList))
                    {
                        recipientAddressFlags |= RecipientAddress.RecipientAddressFlags.DistributionList;
                    }
                    else if (participant.GetValueOrDefault <bool>(ParticipantSchema.IsRoom))
                    {
                        recipientAddressFlags |= RecipientAddress.RecipientAddressFlags.Room;
                    }
                    StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin;
                    if (storeParticipantOrigin != null)
                    {
                        storeObjectId     = storeParticipantOrigin.OriginItemId;
                        emailAddressIndex = storeParticipantOrigin.EmailAddressIndex;
                    }
                    RecipientWellNode.Render(this.Writer, base.UserContext, participant.DisplayName, smtpAddress, participant.EmailAddress, participant.RoutingType, participant.GetValueOrDefault <string>(ParticipantSchema.Alias), RecipientAddress.ToAddressOrigin(participant), (int)recipientAddressFlags, storeObjectId, emailAddressIndex, adObjectId, flag ? RecipientWellNode.RenderFlags.RenderCommas : RecipientWellNode.RenderFlags.None, sipUri, mobilePhoneNumber);
                    flag = true;
                }
            }
        }
        // Token: 0x060000BF RID: 191 RVA: 0x00006CF0 File Offset: 0x00004EF0
        protected override void RenderContents(TextWriter writer, RecipientWellType type, RecipientWellNode.RenderFlags flags)
        {
            if (!this.HasRecipients(type))
            {
                return;
            }
            AdRecipientBatchQuery     adRecipientBatchQuery = new AdRecipientBatchQuery(this.GetRecipientCollection(type), this.UserContext);
            IEnumerator <Participant> recipientCollection   = this.GetRecipientCollection(type);

            RecipientWellNode.RenderFlags renderFlags = flags & ~RecipientWellNode.RenderFlags.RenderCommas;
            bool flag = true;
            RecipientItemType recipientItemType = ItemRecipientWell.GetRecipientItemType(type);
            bool isWebPartRequest = OwaContext.Current.UserContext.IsWebPartRequest;
            int  num = 0;

            while (recipientCollection.MoveNext())
            {
                Participant            participant                = recipientCollection.Current;
                int                    recipientFlags             = 0;
                ADObjectId             adObjectId                 = null;
                int                    readItemType               = 1;
                string                 smtpAddressAndADObjectInfo = ItemRecipientWell.GetSmtpAddressAndADObjectInfo(participant, adRecipientBatchQuery, out adObjectId, out recipientFlags, out readItemType);
                StoreObjectId          storeObjectId              = null;
                StoreParticipantOrigin storeParticipantOrigin     = participant.Origin as StoreParticipantOrigin;
                if (storeParticipantOrigin != null)
                {
                    storeObjectId = storeParticipantOrigin.OriginItemId;
                }
                string idString = ItemRecipientWell.BuildRecipientIdString(recipientItemType, num++);
                if (RecipientWellNode.Render(this.UserContext, writer, participant.DisplayName, smtpAddressAndADObjectInfo, participant.EmailAddress, participant.RoutingType, RecipientAddress.ToAddressOrigin(participant), recipientFlags, readItemType, recipientItemType, adObjectId, storeObjectId, renderFlags, idString, isWebPartRequest) && flag)
                {
                    flag = false;
                    if ((flags & RecipientWellNode.RenderFlags.RenderCommas) != RecipientWellNode.RenderFlags.None)
                    {
                        renderFlags |= RecipientWellNode.RenderFlags.RenderCommas;
                    }
                }
            }
        }