System.Net.AutoWebProxyScriptEngine.ParseScriptReturn C# (CSharp) Method

ParseScriptReturn() private method

private ParseScriptReturn ( string scriptReturn, Uri destination, bool returnFirstOnly ) : StringCollection
scriptReturn string
destination Uri
returnFirstOnly bool
return StringCollection
        private StringCollection ParseScriptReturn(string scriptReturn, Uri destination, bool returnFirstOnly) {
            if (scriptReturn == null)
            {
                return new StringCollection();
            }
            StringCollection proxies = new StringCollection();
            string[] proxyListStrings = scriptReturn.Split(splitChars);
            string proxyAuthority;
            foreach (string s in proxyListStrings)
            {
                string proxyString = s.Trim(' ');
                if (!proxyString.StartsWith("PROXY ", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (string.Compare("DIRECT", proxyString, StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        proxyAuthority = null;
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    proxyAuthority = proxyString.Substring(6).TrimStart(' ');
                    Uri uri = null;
                    bool tryParse = Uri.TryCreate("http://" + proxyAuthority, UriKind.Absolute, out uri);
                    if (!tryParse || uri.UserInfo.Length>0 || uri.HostNameType==UriHostNameType.Basic || uri.AbsolutePath.Length!=1 || proxyAuthority[proxyAuthority.Length-1]=='/' || proxyAuthority[proxyAuthority.Length-1]=='#' || proxyAuthority[proxyAuthority.Length-1]=='?') {
                        continue;
                    }
                }
                proxies.Add(proxyAuthority);
                if (returnFirstOnly) {
                    break;
                }
            }
            return proxies;
        }