Ejemplo n.º 1
0
        internal static void EnabledPrimarySMTPAddressTemplateSetter(object value, IPropertyBag propertyBag)
        {
            ProxyAddressTemplateCollection proxyAddressTemplateCollection = (ProxyAddressTemplateCollection)propertyBag[EmailAddressPolicySchema.RawEnabledEmailAddressTemplates];
            ProxyAddressTemplate           proxyAddressTemplate           = null;

            try
            {
                proxyAddressTemplate = ProxyAddressTemplate.Parse((string)value);
            }
            catch (ArgumentException ex)
            {
                throw new DataValidationException(new PropertyValidationError(new LocalizedString(ex.Message), EmailAddressPolicySchema.EnabledPrimarySMTPAddressTemplate, null), ex);
            }
            if (!(proxyAddressTemplate is SmtpProxyAddressTemplate))
            {
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.ErrorPrimarySmtpTemplateInvalid((string)value), EmailAddressPolicySchema.EnabledPrimarySMTPAddressTemplate, value), null);
            }
            ProxyAddressTemplate proxyAddressTemplate2 = proxyAddressTemplateCollection.FindPrimary(ProxyAddressPrefix.Smtp);

            if (proxyAddressTemplate2 != null && !StringComparer.CurrentCultureIgnoreCase.Equals(proxyAddressTemplate.AddressTemplateString, proxyAddressTemplate2.AddressTemplateString))
            {
                proxyAddressTemplateCollection.Remove(proxyAddressTemplate2);
            }
            proxyAddressTemplateCollection.MakePrimary(proxyAddressTemplate);
        }
Ejemplo n.º 2
0
        internal static object EnabledPrimarySMTPAddressTemplateGetter(IPropertyBag propertyBag)
        {
            ProxyAddressTemplateCollection proxyAddressTemplateCollection = (ProxyAddressTemplateCollection)propertyBag[EmailAddressPolicySchema.RawEnabledEmailAddressTemplates];
            ProxyAddressTemplate           proxyAddressTemplate           = proxyAddressTemplateCollection.FindPrimary(ProxyAddressPrefix.Smtp);

            if (!(null == proxyAddressTemplate))
            {
                return(proxyAddressTemplate.AddressTemplateString);
            }
            return(string.Empty);
        }