Beispiel #1
0
        } // End Function ConvertWebProxy

        public static System.Net.WebProxy ConvertWebProxWrapper(System.Net.IWebProxy iproxy, string type)
        {
            System.Net.WebProxy obj = null;
            if (iproxy == null)
            {
                return(obj);
            }

            System.Type t = iproxy.GetType();

            while (t != null && !string.Equals(t.Name, type, System.StringComparison.InvariantCultureIgnoreCase))
            {
                t = t.BaseType;
            } // Whend

            if (t == null)
            {
                return(obj);
            }

            System.Reflection.FieldInfo fi = t.GetField("webProxy", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

            if (fi == null)
            {
                return(obj);
            }

            obj = (System.Net.WebProxy)fi.GetValue(iproxy);
            return(obj);
        } // End Function ConvertWebProxWrapper
Beispiel #2
0
        } // End Function HTTP_Post

        public static System.Net.WebProxy ConvertWebProxy(System.Net.IWebProxy iproxy)
        {
            System.Net.WebProxy wp = null;

            try
            {
                if (object.ReferenceEquals(iproxy.GetType(), typeof(System.Net.WebProxy)))
                {
                    wp = (System.Net.WebProxy)iproxy;
                }
                if (wp != null)
                {
                    return(wp);
                }

                wp = ConvertWebProxWrapper(iproxy, "WebProxyWrapper");
                if (wp != null)
                {
                    return(wp);
                }

                wp = ConvertWebProxWrapper(iproxy, "WebProxyWrapperOpaque");
                if (wp != null)
                {
                    return(wp);
                }
            }
            catch (System.Exception ex)
            {
                LogLine(ex.Message);
                LogLine(ex.StackTrace);
            }

            return(wp);
        } // End Function ConvertWebProxy