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

Unescape() private static method

private static Unescape ( string str ) : string
str string
return string
        private static string Unescape(string str)
        {
            if (str == null)
                return null;

            StringBuilder sb = null;

            int strLen = str.Length;
            int index; // Pointer into the string that indicates the location of the current '&' character
            int newIndex = 0; // Pointer into the string that indicates the start index of the "remainging" string (that still needs to be processed).

            do
            {
                index = str.IndexOf('&', newIndex);

                if (index == -1)
                {
                    if (sb == null)
                        return str;
                    else
                    {
                        sb.Append(str, newIndex, strLen - newIndex);
                        return sb.ToString();
                    }
                }
                else
                {
                    if (sb == null)
                        sb = new StringBuilder();

                    sb.Append(str, newIndex, index - newIndex);
                    sb.Append(GetUnescapeSequence(str, index, out newIndex)); // updates the newIndex too

                }
            }
            while (true);
        }

Usage Example

Beispiel #1
0
        internal string SearchForTextOfLocalName(string strLocalName)
        {
            if (strLocalName == null)
            {
                throw new ArgumentNullException("strLocalName");
            }
            if (this.m_strTag == null)
            {
                return(null);
            }
            if (this.m_strTag.Equals(strLocalName) || this.m_strTag.EndsWith(":" + strLocalName, StringComparison.Ordinal))
            {
                return(SecurityElement.Unescape(this.m_strText));
            }
            if (this.m_lChildren == null)
            {
                return(null);
            }
            IEnumerator enumerator = this.m_lChildren.GetEnumerator();

            while (enumerator.MoveNext())
            {
                string text = ((SecurityElement)enumerator.Current).SearchForTextOfLocalName(strLocalName);
                if (text != null)
                {
                    return(text);
                }
            }
            return(null);
        }
All Usage Examples Of System.Security.SecurityElement::Unescape