// Constructors

        internal ServicePoint(ServicePointManager.SPKey key, Uri uri, int connectionLimit, int maxIdleTime)
        {
            Key                  = key;
            this.uri             = uri;
            this.connectionLimit = connectionLimit;
            this.maxIdleTime     = maxIdleTime;

            Scheduler = new ServicePointScheduler(this, connectionLimit, maxIdleTime);
        }
        /// <summary>Finds an existing <see cref="T:System.Net.ServicePoint" /> object or creates a new <see cref="T:System.Net.ServicePoint" /> object to manage communications with the specified <see cref="T:System.Uri" /> object.</summary>
        /// <returns>The <see cref="T:System.Net.ServicePoint" /> object that manages communications for the request.</returns>
        /// <param name="address">A <see cref="T:System.Uri" /> object that contains the address of the Internet resource to contact. </param>
        /// <param name="proxy">The proxy data for this request. </param>
        /// <exception cref="T:System.ArgumentNullException">
        ///   <paramref name="address" /> is null. </exception>
        /// <exception cref="T:System.InvalidOperationException">The maximum number of <see cref="T:System.Net.ServicePoint" /> objects defined in <see cref="P:System.Net.ServicePointManager.MaxServicePoints" /> has been reached. </exception>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
        /// </PermissionSet>
        public static ServicePoint FindServicePoint(System.Uri address, IWebProxy proxy)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            ServicePointManager.RecycleServicePoints();
            bool usesProxy = false;
            bool flag      = false;

            if (proxy != null && !proxy.IsBypassed(address))
            {
                usesProxy = true;
                bool flag2 = address.Scheme == "https";
                address = proxy.GetProxy(address);
                if (address.Scheme != "http" && !flag2)
                {
                    throw new NotSupportedException("Proxy scheme not supported.");
                }
                if (flag2 && address.Scheme == "http")
                {
                    flag = true;
                }
            }
            address = new System.Uri(address.Scheme + "://" + address.Authority);
            ServicePoint servicePoint = null;

            System.Collections.Specialized.HybridDictionary obj = ServicePointManager.servicePoints;
            lock (obj)
            {
                ServicePointManager.SPKey key = new ServicePointManager.SPKey(address, flag);
                servicePoint = (ServicePointManager.servicePoints[key] as ServicePoint);
                if (servicePoint != null)
                {
                    return(servicePoint);
                }
                if (ServicePointManager.maxServicePoints > 0 && ServicePointManager.servicePoints.Count >= ServicePointManager.maxServicePoints)
                {
                    throw new InvalidOperationException("maximum number of service points reached");
                }
                string text            = address.ToString();
                int    connectionLimit = ServicePointManager.defaultConnectionLimit;
                servicePoint = new ServicePoint(address, connectionLimit, ServicePointManager.maxServicePointIdleTime);
                servicePoint.Expect100Continue = ServicePointManager.expectContinue;
                servicePoint.UseNagleAlgorithm = ServicePointManager.useNagle;
                servicePoint.UsesProxy         = usesProxy;
                servicePoint.UseConnect        = flag;
                ServicePointManager.servicePoints.Add(key, servicePoint);
            }
            return(servicePoint);
        }
 public override bool Equals(object obj)
 {
     ServicePointManager.SPKey spkey = obj as ServicePointManager.SPKey;
     return(obj != null && this.uri.Equals(spkey.uri) && spkey.use_connect == this.use_connect);
 }