MoreInternals.Model.Selector.BuildEscapeMap C# (CSharp) Метод

BuildEscapeMap() приватный статический Метод

Determines which string sequences in a selector are escape sequences, and replaces them with characters that have no meaning in CSS (and don't appear elsewhere in the selector). Returns a dictionary[char, string] that can be used to reverse this transformation.
private static BuildEscapeMap ( string &rawSelector ) : string>.Dictionary
rawSelector string
Результат string>.Dictionary
        private static Dictionary<char, string> BuildEscapeMap(ref string rawSelector)
        {
            var ret = new Dictionary<char, string>();
            var cleaned = new List<char>();

            bool inEscape = false;
            int escapeStarts = -1;

            for (var i = 0; i < rawSelector.Length; i++)
            {
                var c = rawSelector[i];

                if (c == '\\')
                {
                    inEscape = true;
                    escapeStarts = i;
                    continue;
                }

                if (!inEscape)
                {
                    cleaned.Add(c);
                    continue;
                }

                // special character! (maybe!)
                if (!char.IsLetterOrDigit(c) && i == escapeStarts + 1)
                {
                    var replacement = NextSpecialChar(ret.Keys, rawSelector);

                    ret[replacement] = "\\" + c;
                    cleaned.Add(replacement);
                    inEscape = false;
                    continue;
                }

                if (c == ' ' || (i - escapeStarts == 7))
                {
                    var sequence = rawSelector.Substring(escapeStarts, i - escapeStarts + 1);

                    var replacement = NextSpecialChar(ret.Keys, rawSelector);

                    ret[replacement] = sequence;

                    cleaned.Add(replacement);
                    inEscape = false;
                    continue;
                }
            }

            rawSelector = new string(cleaned.ToArray());

            return ret;
        }