예제 #1
0
 public static ProxyAddressPrefix[] GetStandardPrefixes()
 {
     ProxyAddressPrefix[] array = new ProxyAddressPrefix[ProxyAddressPrefix.standardPrefixes.Count + 1];
     ProxyAddressPrefix.standardPrefixes.Values.CopyTo(array, 0);
     array[array.Length - 1] = ProxyAddressPrefix.GetCustomProxyAddressPrefix();
     return(array);
 }
        private static ProxyAddressTemplate Parse(string proxyAddressTemplateString, string prefixString, string addressTemplateString)
        {
            if (prefixString == null)
            {
                throw new ArgumentNullException("prefixString");
            }
            if (addressTemplateString == null)
            {
                throw new ArgumentNullException("addressTemplateString");
            }
            ProxyAddressPrefix proxyAddressPrefix;

            if (prefixString.Length == 0 && SmtpProxyAddressTemplate.IsValidSmtpAddressTemplate(addressTemplateString))
            {
                proxyAddressPrefix = ProxyAddressPrefix.Smtp;
            }
            else
            {
                proxyAddressPrefix = ProxyAddressPrefix.GetPrefix(prefixString);
            }
            bool flag = StringComparer.Ordinal.Equals(proxyAddressPrefix.PrimaryPrefix, prefixString);
            ProxyAddressTemplate result;

            try
            {
                ProxyAddressTemplate proxyAddressTemplate = proxyAddressPrefix.GetProxyAddressTemplate(addressTemplateString, flag);
                proxyAddressTemplate.RawProxyAddressBaseString = proxyAddressTemplateString;
                result = proxyAddressTemplate;
            }
            catch (ArgumentOutOfRangeException parseException)
            {
                result = new InvalidProxyAddressTemplate(proxyAddressTemplateString, proxyAddressPrefix, addressTemplateString, flag, parseException);
            }
            return(result);
        }
예제 #3
0
 public InvalidProxyAddress(string proxyAddressString, ProxyAddressPrefix prefix, string address, bool isPrimaryAddress, ArgumentOutOfRangeException parseException) : base(prefix, address, isPrimaryAddress, true)
 {
     if (parseException == null)
     {
         throw new ArgumentNullException("parseException", "An invalid proxy address must contain the exception that makes it invalid.");
     }
     base.RawProxyAddressBaseString = proxyAddressString;
     this.parseException            = parseException;
 }
 protected ProxyAddressTemplate(ProxyAddressPrefix prefix, string addressTemplateString, bool isPrimaryAddress) : base(prefix, addressTemplateString, isPrimaryAddress)
 {
     if (prefix.DisplayName.Length == 0)
     {
         throw new ArgumentException(DataStrings.ProxyAddressTemplateEmptyPrefixOrValue(this.ProxyAddressTemplateString));
     }
     if (addressTemplateString.Length == 0)
     {
         throw new ArgumentException(DataStrings.ProxyAddressTemplateEmptyPrefixOrValue(this.ProxyAddressTemplateString));
     }
 }
예제 #5
0
        private static ProxyAddress Parse(string proxyAddressString, string prefixString, string addressString)
        {
            if (prefixString == null)
            {
                throw new ArgumentNullException("prefixString");
            }
            if (addressString == null)
            {
                throw new ArgumentNullException("addressString");
            }
            ProxyAddressPrefix proxyAddressPrefix;

            if (prefixString.Length == 0 && SmtpAddress.IsValidSmtpAddress(addressString))
            {
                proxyAddressPrefix = ProxyAddressPrefix.Smtp;
            }
            else
            {
                try
                {
                    proxyAddressPrefix = ProxyAddressPrefix.GetPrefix(prefixString);
                }
                catch (ArgumentOutOfRangeException parseException)
                {
                    return(new InvalidProxyAddress(proxyAddressString, new CustomProxyAddressPrefix("ERROR"), proxyAddressString ?? (prefixString + ':' + addressString), true, parseException));
                }
                catch (ArgumentException ex)
                {
                    return(new InvalidProxyAddress(proxyAddressString, new CustomProxyAddressPrefix("ERROR"), proxyAddressString ?? (prefixString + ':' + addressString), true, new ArgumentOutOfRangeException(ex.Message, ex)));
                }
            }
            bool         isPrimaryAddress = StringComparer.Ordinal.Equals(proxyAddressPrefix.PrimaryPrefix, prefixString);
            ProxyAddress result;

            try
            {
                ProxyAddress proxyAddress = proxyAddressPrefix.GetProxyAddress(addressString, isPrimaryAddress);
                proxyAddress.RawProxyAddressBaseString = proxyAddressString;
                result = proxyAddress;
            }
            catch (ArgumentOutOfRangeException parseException2)
            {
                result = new InvalidProxyAddress(proxyAddressString, proxyAddressPrefix, addressString, isPrimaryAddress, parseException2);
            }
            return(result);
        }
예제 #6
0
 protected ProxyAddressBase(ProxyAddressPrefix prefix, string valueString, bool isPrimaryAddress, bool suppressAddressValidation)
 {
     if (null == prefix)
     {
         throw new ArgumentNullException("prefix");
     }
     if (valueString == null)
     {
         throw new ArgumentNullException("valueString");
     }
     if (!suppressAddressValidation)
     {
         ProxyAddressBase.ValidateAddressString(valueString);
     }
     this.prefix           = prefix;
     this.valueString      = valueString;
     this.isPrimaryAddress = isPrimaryAddress;
 }
        public T FindPrimary(ProxyAddressPrefix prefix)
        {
            T result = default(T);

            for (int i = 0; i < this.Count; i++)
            {
                T t = base[i];
                if (t.IsPrimaryAddress)
                {
                    T t2 = base[i];
                    if (t2.Prefix == prefix)
                    {
                        result = base[i];
                        break;
                    }
                }
            }
            return(result);
        }
예제 #8
0
 private void Initialize(string addressType, string addressSpace, int cost, bool includeSubDomain, bool performFullAddressTypeValidation)
 {
     if (string.IsNullOrEmpty(addressType))
     {
         throw new StrongTypeFormatException(DataStrings.InvalidAddressSpaceTypeNullOrEmpty, "Type");
     }
     this.type = addressType;
     this.Cost = cost;
     if (this.IsSmtpType)
     {
         this.smtpDomainWithSubdomains = new SmtpDomainWithSubdomains(addressSpace, includeSubDomain);
         return;
     }
     if (addressSpace != null)
     {
         addressSpace = addressSpace.ToLower();
     }
     if (this.IsX400Type)
     {
         if (!RoutingX400Address.TryParseAddressSpace(addressSpace, this.isLocal, out this.x400Address))
         {
             throw new StrongTypeFormatException(DataStrings.InvalidX400AddressSpace(addressSpace), "Domain");
         }
         this.addressSpace = addressSpace;
         return;
     }
     else
     {
         if (string.IsNullOrEmpty(addressSpace))
         {
             throw new StrongTypeFormatException(DataStrings.InvalidAddressSpaceAddress, "Domain");
         }
         if (performFullAddressTypeValidation && !ProxyAddressPrefix.IsPrefixStringValid(addressType))
         {
             throw new StrongTypeFormatException(DataStrings.InvalidAddressSpaceType(addressType), "Type");
         }
         this.addressSpace = addressSpace.Replace("(a)", "@");
         return;
     }
 }
        public override bool Remove(T item)
        {
            if (base.CopyChangesOnly || this.AutoPromotionDisabled)
            {
                return(base.Remove(item));
            }
            int num = base.IndexOf(item);

            if (-1 != num)
            {
                item = base[num];
            }
            if (item.IsPrimaryAddress && item.Prefix == ProxyAddressPrefix.Smtp)
            {
                bool flag = false;
                for (int i = 0; i < this.Count; i++)
                {
                    T t = base[i];
                    if (t.IsPrimaryAddress)
                    {
                        T t2 = base[i];
                        if (t2.Prefix == ProxyAddressPrefix.Smtp && base[i] != item && !(base[i] is IInvalidProxy))
                        {
                            flag = true;
                            break;
                        }
                    }
                }
                if (!flag)
                {
                    throw new InvalidOperationException(DataStrings.ExceptionRemoveSmtpPrimary(item.ValueString));
                }
            }
            base.BeginUpdate();
            try
            {
                if (!base.Remove(item))
                {
                    return(false);
                }
                if (item.IsPrimaryAddress)
                {
                    ProxyAddressPrefix prefix = item.Prefix;
                    if (null == this.FindPrimary(prefix))
                    {
                        for (int j = 0; j < this.Count; j++)
                        {
                            T t3 = base[j];
                            if (t3.Prefix == prefix && !(base[j] is IInvalidProxy))
                            {
                                T t4    = base[j];
                                T value = (T)((object)t4.ToPrimary());
                                base.RemoveAt(j);
                                this.Insert(j, value);
                                break;
                            }
                        }
                    }
                }
            }
            finally
            {
                base.EndUpdate();
            }
            return(true);
        }
예제 #10
0
 protected ProxyAddressBase(ProxyAddressPrefix prefix, string valueString, bool isPrimaryAddress) : this(prefix, valueString, isPrimaryAddress, false)
 {
 }
예제 #11
0
 protected ProxyAddress(ProxyAddressPrefix prefix, string addressString, bool isPrimaryAddress) : this(prefix, addressString, isPrimaryAddress, false)
 {
 }
예제 #12
0
 protected ProxyAddress(ProxyAddressPrefix prefix, string addressString, bool isPrimaryAddress, bool suppressAddressValidation) : base(prefix, addressString, isPrimaryAddress, suppressAddressValidation)
 {
 }
예제 #13
0
 public static bool IsPrefixStringValid(string prefixString)
 {
     return(ProxyAddressPrefix.CheckPrefixString(prefixString, false));
 }
예제 #14
0
 protected ProxyAddressPrefix(string prefixString)
 {
     ProxyAddressPrefix.CheckPrefixString(prefixString, true);
     this.primaryPrefix   = prefixString.ToUpperInvariant();
     this.secondaryPrefix = prefixString.ToLowerInvariant();
 }