예제 #1
0
        private bool IsDirective(StringSection directiveName)
        {
            int listStart = 0;
            int listEnd   = directiveNames.Length / 2; // Exclusive

            int listCount = listEnd - listStart;

            while (listCount > 1)
            {
                // first item of second half
                int split = listStart + listCount / 2;

                var splitText = directiveNames[split];
                var compare   = StringSection.Compare(directiveName, splitText, true);
                if (compare == 0)
                {
                    return(true);
                }
                if (compare > 0)   // directiveName > splitText
                {
                    listStart = split;
                }
                else
                {
                    listEnd = split;
                }

                listCount = listEnd - listStart;
            }
            return(StringSection.Compare(directiveName, directiveNames[listStart], true) == 0);
        }
예제 #2
0
        private bool IsIncludeLine(StringSection line)
        {
            if (line.Length < includeDirective.Length)
            {
                return(false);
            }
            var lineStart = line.Substring(0, includeDirective.Length);

            if (StringSection.Compare(lineStart, includeDirective, true) == 0)
            {
                return(true);
            }
            return(false);
        }
예제 #3
0
 private static bool StringEquals(StringSection a, StringSection b, bool ignoreCase)
 {
     return(StringSection.Compare(a, b, ignoreCase) == 0);
 }