ToString() public method

public ToString ( ) : string
return string
Example #1
0
 private static bool isSpecialSubsetCase(string regexToCheck, ArrayList permList)
 {
     foreach (object obj2 in permList)
     {
         DelayedRegex regex = obj2 as DelayedRegex;
         if (regex != null)
         {
             if (string.Compare(regexToCheck, regex.ToString(), StringComparison.OrdinalIgnoreCase) == 0)
             {
                 return(true);
             }
         }
         else
         {
             Uri uri = obj2 as Uri;
             if (uri != null)
             {
                 if (string.Compare(regexToCheck, Regex.Escape(uri.GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped)), StringComparison.OrdinalIgnoreCase) == 0)
                 {
                     return(true);
                 }
             }
             else if (string.Compare(regexToCheck, Regex.Escape(obj2.ToString()), StringComparison.OrdinalIgnoreCase) == 0)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #2
0
        internal void AddAsPattern(NetworkAccess access, DelayedRegex uriRegexPattern)
        {
            ArrayList list = new ArrayList();

            if (((access & NetworkAccess.Connect) != 0) && !this.m_UnrestrictedConnect)
            {
                list.Add(this.m_connectList);
            }
            if (((access & NetworkAccess.Accept) != 0) && !this.m_UnrestrictedAccept)
            {
                list.Add(this.m_acceptList);
            }
            foreach (ArrayList list2 in list)
            {
                bool flag = false;
                foreach (object obj2 in list2)
                {
                    if ((obj2 is DelayedRegex) && (string.Compare(uriRegexPattern.ToString(), obj2.ToString(), StringComparison.OrdinalIgnoreCase) == 0))
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    list2.Add(uriRegexPattern);
                }
            }
        }
Example #3
0
        //Checks special case when testing Regex to be a subset of other Regex
        //Support only the case when  both Regexes are identical as strings.
        private static bool isSpecialSubsetCase(String regexToCheck, ArrayList permList)
        {
            Uri uri;

            foreach (object uriPattern in permList)
            {
                DelayedRegex regex = uriPattern as DelayedRegex;
                if (regex != null)
                {
                    //regex parameter against regex permission
                    if (String.Compare(regexToCheck, regex.ToString(), StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return(true);
                    }
                }
                else if ((uri = uriPattern as Uri) != null)
                {
                    //regex parameter against Uri permission
                    if (String.Compare(regexToCheck, Regex.Escape(uri.GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped)), StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return(true);
                    }
                }
                else if (String.Compare(regexToCheck, Regex.Escape(uriPattern.ToString()), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    //regex parameter against string permission
                    return(true);
                }
            }

            return(false);
        }
Example #4
0
        //  Overloaded form using string inputs
        //  Enforces case-insensitive matching
        /// Adds a new instance of the System.Net.WebPermission
        /// class with the specified access rights for the specified URI Pattern
        internal void AddAsPattern(NetworkAccess access, DelayedRegex uriRegexPattern)
        {
            ArrayList lists = new ArrayList();

            if ((access & NetworkAccess.Connect) != 0 && !m_UnrestrictedConnect)
            {
                lists.Add(m_connectList);
            }
            if ((access & NetworkAccess.Accept) != 0 && !m_UnrestrictedAccept)
            {
                lists.Add(m_acceptList);
            }

            foreach (ArrayList list in lists)
            {
                // avoid duplicated regexes in the list
                bool found = false;
                foreach (object obj in list)
                {
                    if ((obj is DelayedRegex) && (string.Compare(uriRegexPattern.ToString(), obj.ToString(), StringComparison.OrdinalIgnoreCase) == 0))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    list.Add(uriRegexPattern);
                }
            }
        }
Example #5
0
        private static object intersectPair(object L, object R, out bool isUri)
        {
            //VERY OLD OPTION:  return new Regex("(?=(" + ((Regex)X[i]).ToString()+ "))(" + ((Regex)Y[j]).ToString() + ")","i");
            //STILL OLD OPTION: return new Regex("(?=.*?(" + L.ToString() + "))" + "(?=.*?(" + R.ToString() + "))");
            // check RegexSpec.doc
            //CURRENT OPTION:   return new Regex("(?=(" + L.ToString() + "))(" + R.ToString() + ")", RegexOptions.IgnoreCase );
            isUri = false;
            DelayedRegex L_Pattern = L as DelayedRegex;
            DelayedRegex R_Pattern = R as DelayedRegex;

            if (L_Pattern != null && R_Pattern != null)          //both are Regex
            {
                return(new DelayedRegex("(?=(" + L_Pattern.ToString() + "))(" + R_Pattern.ToString() + ")"));
            }
            else if (L_Pattern != null && R_Pattern == null)     //only L is a Regex
            {
                isUri = R is Uri;
                string uriString = isUri? ((Uri)R).GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped): R.ToString();

                Match M = L_Pattern.AsRegex.Match(uriString);
                if ((M != null) &&                           // Found match for the regular expression?
                    (M.Index == 0) &&                        // ... which starts at the begining
                    (M.Length == uriString.Length))          // ... and the whole string matched
                {
                    return(R);
                }
                return(null);
            }
            else if (L_Pattern == null && R_Pattern != null)     //only R is a Regex
            {
                isUri = L is Uri;
                string uriString = isUri? ((Uri)L).GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped):  L.ToString();
                Match  M         = R_Pattern.AsRegex.Match(uriString);
                if ((M != null) &&                           // Found match for the regular expression?
                    (M.Index == 0) &&                        // ... which starts at the begining
                    (M.Length == uriString.Length))          // ... and the whole string matched
                {
                    return(L);
                }
                return(null);
            }
            //both are Uris or strings
            isUri = L is Uri;
            if (isUri)
            {
                return(L.Equals(R)? L : null);
            }
            else
            {
                return(string.Compare(L.ToString(), R.ToString(), StringComparison.OrdinalIgnoreCase) == 0? L : null);
            }
        }
Example #6
0
        private static object intersectPair(object L, object R, out bool isUri)
        {
            isUri = false;
            DelayedRegex regex  = L as DelayedRegex;
            DelayedRegex regex2 = R as DelayedRegex;

            if ((regex != null) && (regex2 != null))
            {
                return(new DelayedRegex("(?=(" + regex.ToString() + "))(" + regex2.ToString() + ")"));
            }
            if ((regex != null) && (regex2 == null))
            {
                isUri = R is Uri;
                string input = isUri ? ((Uri)R).GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped) : R.ToString();
                Match  match = regex.AsRegex.Match(input);
                if (((match != null) && (match.Index == 0)) && (match.Length == input.Length))
                {
                    return(R);
                }
                return(null);
            }
            if ((regex == null) && (regex2 != null))
            {
                isUri = L is Uri;
                string str2   = isUri ? ((Uri)L).GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped) : L.ToString();
                Match  match2 = regex2.AsRegex.Match(str2);
                if (((match2 != null) && (match2.Index == 0)) && (match2.Length == str2.Length))
                {
                    return(L);
                }
                return(null);
            }
            isUri = L is Uri;
            if (isUri)
            {
                if (!L.Equals(R))
                {
                    return(null);
                }
                return(L);
            }
            if (string.Compare(L.ToString(), R.ToString(), StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(null);
            }
            return(L);
        }
 internal void AddAsPattern(NetworkAccess access, DelayedRegex uriRegexPattern)
 {
     ArrayList list = new ArrayList();
     if (((access & NetworkAccess.Connect) != 0) && !this.m_UnrestrictedConnect)
     {
         list.Add(this.m_connectList);
     }
     if (((access & NetworkAccess.Accept) != 0) && !this.m_UnrestrictedAccept)
     {
         list.Add(this.m_acceptList);
     }
     foreach (ArrayList list2 in list)
     {
         bool flag = false;
         foreach (object obj2 in list2)
         {
             if ((obj2 is DelayedRegex) && (string.Compare(uriRegexPattern.ToString(), obj2.ToString(), StringComparison.OrdinalIgnoreCase) == 0))
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             list2.Add(uriRegexPattern);
         }
     }
 }
Example #8
0
        //  Overloaded form using string inputs
        //  Enforces case-insensitive matching
        /// Adds a new instance of the System.Net.WebPermission
        /// class with the specified access rights for the specified URI Pattern
        internal void AddAsPattern(NetworkAccess access, DelayedRegex uriRegexPattern)
        {
            ArrayList lists = new ArrayList();
            if ((access & NetworkAccess.Connect) != 0 && !m_UnrestrictedConnect)
                lists.Add(m_connectList);
            if ((access & NetworkAccess.Accept) != 0 && !m_UnrestrictedAccept)
                lists.Add(m_acceptList);

            foreach (ArrayList list in lists)
            {
                // avoid duplicated regexes in the list
                bool found = false;
                foreach (object obj in list) {
                    if ((obj is DelayedRegex) && (string.Compare(uriRegexPattern.ToString(), obj.ToString(), StringComparison.OrdinalIgnoreCase ) == 0)) {
                        found = true;
                        break;
                    }
                }

                if (!found) {
                    list.Add(uriRegexPattern);
                }
            }
        }