System.Security.SecurityElement.GetUnescapeSequence C# (CSharp) Method

GetUnescapeSequence() private static method

private static GetUnescapeSequence ( string str, int index, int &newIndex ) : string
str string
index int
newIndex int
return string
        private static string GetUnescapeSequence(string str, int index, out int newIndex)
        {
            int maxCompareLength = str.Length - index;

            int iMax = s_escapeStringPairs.Length;
            Debug.Assert(iMax % 2 == 0, "Odd number of strings means the attr/value pairs were not added correctly");

            for (int i = 0; i < iMax; i += 2)
            {
                string strEscSeq = s_escapeStringPairs[i];
                string strEscValue = s_escapeStringPairs[i + 1];

                int length = strEscValue.Length;

                if (length <= maxCompareLength && string.Compare(strEscValue, 0, str, index, length, StringComparison.Ordinal) == 0)
                {
                    newIndex = index + strEscValue.Length;
                    return strEscSeq;
                }
            }

            newIndex = index + 1;
            return str[index].ToString();
        }

Usage Example

Beispiel #1
0
        private static string Unescape(string str)
        {
            if (str == null)
            {
                return(null);
            }
            StringBuilder stringBuilder = null;
            int           length        = str.Length;
            int           num           = 0;

            while (true)
            {
                int num2 = str.IndexOf('&', num);
                if (num2 == -1)
                {
                    break;
                }
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append(str, num, num2 - num);
                stringBuilder.Append(SecurityElement.GetUnescapeSequence(str, num2, out num));
            }
            if (stringBuilder == null)
            {
                return(str);
            }
            stringBuilder.Append(str, num, length - num);
            return(stringBuilder.ToString());
        }
All Usage Examples Of System.Security.SecurityElement::GetUnescapeSequence