private void VerifyAndAddRecipient(ReducedRecipient recipient, MultiValuedProperty <BindingMetadata> validatedRecipients, bool inGroupExpansion)
 {
     if (ExchangeValidator.IsValidRecipientType(recipient))
     {
         if (!validatedRecipients.Any((BindingMetadata p) => string.Equals(recipient.ExternalDirectoryObjectId, p.ImmutableIdentity, StringComparison.OrdinalIgnoreCase)))
         {
             if (validatedRecipients.Count < this.maxRecipientsLimit)
             {
                 validatedRecipients.Add(new BindingMetadata(recipient.Name, recipient.PrimarySmtpAddress.ToString(), recipient.ExternalDirectoryObjectId, PolicyBindingTypes.IndividualResource));
                 return;
             }
             base.LogOneEntry(ExecutionLog.EventType.Error, "InvalidArgument: {0}", new object[]
             {
                 Strings.ErrorMaxMailboxLimitReachedInGroupExpansion(this.maxRecipientsLimit)
             });
             base.WriteError(new ExValidatorException(Strings.ErrorMaxMailboxLimitReachedInGroupExpansion(this.maxRecipientsLimit)), ErrorCategory.InvalidArgument);
             return;
         }
     }
     else
     {
         if (inGroupExpansion)
         {
             if (!this.warnedSkipInvalidTypeInGroup)
             {
                 this.warnedSkipInvalidTypeInGroup = true;
                 base.WriteWarning(Strings.SkippingInvalidTypeInGroupExpansion);
             }
             base.LogOneEntry(ExecutionLog.EventType.Warning, "Invalid group member '{0}' skipped as the type '{1}' is not supported", new object[]
             {
                 recipient.PrimarySmtpAddress.ToString(),
                 recipient.RecipientTypeDetails
             });
             return;
         }
         base.LogOneEntry(ExecutionLog.EventType.Error, "InvalidArgument: {0}", new object[]
         {
             Strings.ErrorInvalidRecipientType(recipient.PrimarySmtpAddress.ToString(), recipient.RecipientTypeDetails.ToString())
         });
         base.WriteError(new ExValidatorException(Strings.ErrorInvalidRecipientType(recipient.PrimarySmtpAddress.ToString(), recipient.RecipientTypeDetails.ToString())), ErrorCategory.InvalidArgument);
     }
 }
        private MultiValuedProperty <BindingMetadata> ValidateRecipientsImpl(IEnumerable <string> recipients)
        {
            MultiValuedProperty <BindingMetadata> multiValuedProperty = new MultiValuedProperty <BindingMetadata>();
            bool flag = false;

            this.warnedSkipInvalidTypeInGroup = false;
            if (recipients.Count <string>() > this.maxRecipientsLimit)
            {
                base.LogOneEntry(ExecutionLog.EventType.Error, "InvalidArgument: {0}", new object[]
                {
                    Strings.ErrorMaxMailboxLimit(this.maxRecipientsLimit, recipients.Count <string>())
                });
                base.WriteError(new ExValidatorException(Strings.ErrorMaxMailboxLimit(this.maxRecipientsLimit, recipients.Count <string>())), ErrorCategory.InvalidArgument);
            }
            else
            {
                foreach (string text in recipients)
                {
                    if (SourceValidator.IsWideScope(text))
                    {
                        base.LogOneEntry(ExecutionLog.EventType.Verbose, "Skipping validation for wide scoped value '{0}", new object[]
                        {
                            text
                        });
                        multiValuedProperty.Add(new BindingMetadata(text, text, text, SourceValidator.GetBindingType(text)));
                    }
                    else
                    {
                        RecipientIdParameter recipientIdParameter = RecipientIdParameter.Parse(text);
                        ReducedRecipient     reducedRecipient     = this.recipientGetter(recipientIdParameter, this.recipientSession);
                        if (ExchangeValidator.IsMembershipGroup(reducedRecipient) && this.allowGroups)
                        {
                            if (!flag)
                            {
                                if (base.ShouldContinue(Strings.ShouldExpandGroups))
                                {
                                    flag = true;
                                    base.LogOneEntry(ExecutionLog.EventType.Information, "Got confirmation to expand groups", new object[0]);
                                }
                                else
                                {
                                    base.LogOneEntry(ExecutionLog.EventType.Error, "User selected not to expand groups. {0}", new object[]
                                    {
                                        Strings.GroupsIsNotAllowedForHold(recipientIdParameter.RawIdentity)
                                    });
                                    base.WriteError(new ExValidatorException(Strings.GroupsIsNotAllowedForHold(recipientIdParameter.RawIdentity)), ErrorCategory.InvalidArgument);
                                }
                            }
                            if (flag)
                            {
                                this.ExpandGroupMembership(reducedRecipient, multiValuedProperty);
                            }
                        }
                        else
                        {
                            this.VerifyAndAddRecipient(reducedRecipient, multiValuedProperty, false);
                        }
                    }
                }
            }
            return(multiValuedProperty);
        }