Headless.QueryFactory.CaseQuery C# (CSharp) Method

CaseQuery() public static method

Returns the query as either a case sensitive or case insensitive query.
public static CaseQuery ( string queryPart, bool ignoreCase ) : string
queryPart string /// The part of the query to process. ///
ignoreCase bool /// if set to true the query will ignore case. ///
return string
        public static string CaseQuery(string queryPart, bool ignoreCase)
        {
            if (ignoreCase)
            {
                return "translate(" + queryPart + ", 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')";
            }

            return queryPart;
        }

Usage Example

示例#1
0
        private static string BuildTagExpression(SupportedTagAttribute supportedTag)
        {
            // HTML tag names are case folded to lower case
            var queryTagName = supportedTag.TagName.ToLowerInvariant();

            if (supportedTag.HasAttributeFilter)
            {
                const string AttributeFilterQuery = "*[local-name() = '{0}' and {1}='{2}']";

                // HTML attribute names are case folded to lower case
                // Searching by the SupportedTagAttribute attribute value must be case insensitive
                var attributeName      = supportedTag.AttributeName.ToLowerInvariant();
                var queryAttributeName = QueryFactory.CaseQuery("@" + attributeName, true);

                // This literal value can be converted to lower case here rather than within the execution of the XPath query
                var queryAttributeValue = supportedTag.AttributeValue.ToLowerInvariant();

                return(string.Format(
                           CultureInfo.CurrentCulture,
                           AttributeFilterQuery,
                           queryTagName,
                           queryAttributeName,
                           queryAttributeValue));
            }

            return("*[local-name() = '" + queryTagName + "']");
        }
All Usage Examples Of Headless.QueryFactory::CaseQuery