public static bool TryParse(string combo, out ProxyEx result)
        {
            result = new ProxyEx();

            string[] parts = combo.Split(':');

            if (parts.Length != 2 && parts.Length != 4)
            {
                //throw new ArgumentException("proxyCombo must be in the format IP:PORT or IP:PORT:USERNAME:PASSWORD");

                return(false);
            }

            int port = 0;

            if (!Int32.TryParse(parts[1], out port))
            {
                //throw new ArgumentException(String.Format("Invalid port value \"{0}\"", parts[1]));

                return(false);
            }

            result.Address = parts[0];
            result.Port    = port;

            if (parts.Length == 4)
            {
                result.Username = parts[2];
                result.Password = parts[3];
            }

            return(true);
        }
        public override bool Equals(object obj)
        {
            ProxyEx proxyEx = obj as ProxyEx;

            if (proxyEx == null)
            {
                return(base.Equals(obj));
            }

            return(proxyEx.Address == this.Address && proxyEx.Port == this.Port);
        }
示例#3
0
        public bool AddProxy(string data)
        {
            ProxyEx proxy = null;

            if (!ProxyEx.TryParse(data, out proxy))
            {
                return false;
            }


            GoProxy goProxy = new GoProxy
            {
                Address = proxy.Address,
                Password = proxy.Password,
                Port = proxy.Port,
                Username = proxy.Username
            };

            return AddProxy(goProxy);
        }