コード例 #1
0
        private MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationTuple SetList(MultiValuedProperty <string> addresses, JunkEmailCollection junkEmails, JunkEmailCollection junkDomains)
        {
            List <string> list  = new List <string>();
            List <string> list2 = new List <string>();

            string[] array = this.CullEmailsAndDomains(addresses, list, list2);
            foreach (string text in array)
            {
                if (junkEmails.Contains(text))
                {
                    list.Add(text);
                }
                else
                {
                    if (!junkDomains.Contains(text))
                    {
                        return(new MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationTuple(MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsMalformatted, text));
                    }
                    list2.Add(text);
                }
            }
            MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationTuple result = this.SetDelta(list.ToArray(), junkEmails, new MailboxJunkEmailConfigurationDataProvider.JunkEmailAdditionStrategy(this.SetEmailsList));
            if (result.Problem != MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsGood)
            {
                return(result);
            }
            return(this.SetDelta(list2.ToArray(), junkDomains, new MailboxJunkEmailConfigurationDataProvider.JunkEmailAdditionStrategy(this.SetDomainsList)));
        }
コード例 #2
0
        private void SetTrustedList(MailboxJunkEmailConfiguration o, JunkEmailRule rule)
        {
            MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationTuple junkEmailValidationTuple = this.SetList(o.TrustedSendersAndDomains, rule.TrustedSenderEmailCollection, rule.TrustedSenderDomainCollection);
            if (junkEmailValidationTuple.Problem == MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsGood)
            {
                junkEmailValidationTuple = this.SetList(o.TrustedSendersAndDomains, rule.TrustedRecipientEmailCollection, rule.TrustedRecipientDomainCollection);
            }
            LocalizedString localizedString = LocalizedString.Empty;

            switch (junkEmailValidationTuple.Problem)
            {
            case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsUsersEmailOrDomain:
                localizedString = ServerStrings.JunkEmailTrustedListOwnersEmailAddressException(junkEmailValidationTuple.Address);
                goto IL_EB;

            case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsInternalToOrganization:
                localizedString = ServerStrings.JunkEmailTrustedListInternalToOrganizationException(junkEmailValidationTuple.Address);
                goto IL_EB;

            case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsDuplicate:
                localizedString = ServerStrings.JunkEmailTrustedListXsoDuplicateException(junkEmailValidationTuple.Address);
                goto IL_EB;

            case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsEmpty:
                localizedString = ServerStrings.JunkEmailTrustedListXsoEmptyException;
                goto IL_EB;

            case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsMalformatted:
                localizedString = ServerStrings.JunkEmailTrustedListXsoFormatException(junkEmailValidationTuple.Address);
                goto IL_EB;

            case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsNull:
                localizedString = ServerStrings.JunkEmailTrustedListXsoNullException;
                goto IL_EB;

            case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsTooBig:
                localizedString = ServerStrings.JunkEmailTrustedListXsoTooBigException(junkEmailValidationTuple.Address);
                goto IL_EB;

            case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsFull:
                localizedString = ServerStrings.JunkEmailTrustedListXsoTooManyException;
                goto IL_EB;

            case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsGood:
                goto IL_EB;
            }
            localizedString = ServerStrings.JunkEmailTrustedListXsoGenericException(junkEmailValidationTuple.Address);
IL_EB:
            if (localizedString != LocalizedString.Empty)
            {
                PropertyValidationError propertyValidationError = new PropertyValidationError(localizedString, MailboxJunkEmailConfigurationSchema.TrustedSendersAndDomains, o.TrustedSendersAndDomains);
                throw new PropertyValidationException(localizedString.ToString(), propertyValidationError.PropertyDefinition, new PropertyValidationError[]
                {
                    propertyValidationError
                });
            }
        }