System.Net.WebPermission.isMatchedURI C# (CSharp) Method

isMatchedURI() private static method

private static isMatchedURI ( object uriToCheck, ArrayList uriPatternList ) : bool
uriToCheck object
uriPatternList System.Collections.ArrayList
return bool
        private static bool isMatchedURI(object uriToCheck, ArrayList uriPatternList) {

            string stringUri = uriToCheck as string;

            foreach(object uriPattern in uriPatternList) {
                DelayedRegex R = uriPattern as DelayedRegex;

                //perform case insensitive comparison of final URIs or strings, a Uri is never equal compares a string (strings are invalid Uris)
                if(R == null) {
                    if (uriToCheck.GetType() == uriPattern.GetType())
                    {
                        if (stringUri != null && string.Compare(stringUri, (string)uriPattern, StringComparison.OrdinalIgnoreCase ) == 0) {
                            return true;
                        }
                        else if(stringUri == null && uriToCheck.Equals(uriPattern)) {
                            return true;
                        }
                    }
                    continue;
                }

                //Otherwise trying match final URI against given Regex pattern
                string s = stringUri != null? stringUri: ((Uri)uriToCheck).GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped);
                Match M = R.AsRegex.Match(s);
                if ((M != null)                             // Found match for the regular expression?
                    && (M.Index == 0)                       // ... which starts at the begining
                    && (M.Length == s.Length)) {            // ... and the whole string matched
                    return true;
                }

                if (stringUri != null)
                    continue;
                //
                // check if the URI was presented in non-canonical form
                //
                s = ((Uri)uriToCheck).GetComponents(UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped);
                M = R.AsRegex.Match(s);
                if ((M != null)                             // Found match for the regular expression?
                    && (M.Index == 0)                       // ... which starts at the begining
                    && (M.Length == s.Length)) {   // ... and the whole string matched
                    return true;
                }
            }
            return false;
        }