private TokenFilter getFilter(XmlNode n, bool allow_implied)
        {
            TokenFilter filter = new TokenFilter();

            if (n.Attributes["target"] != null)
            {
                filter.Target = n.Attributes["target"].Value == "sorting" ? TokenMatchTarget.Sorting : n.Attributes["target"].Value == "filtering" ? TokenMatchTarget.Filtering : TokenMatchTarget.All;
            }
            filter.IsAllowed       = n.Attributes["allowed"] == null ? !allow_implied : n.Attributes["allowed"].Value.ToLower() == "true" ? true : false;
            filter.IsCaseSensitive = n.Attributes["case-sensitive"] != null && n.Attributes["case-sensitive"].Value.ToLower() == "true";
            string expr = n.Attributes["expr"].Value.Trim();

            if (expr.StartsWith("*") && expr.EndsWith("*"))
            {
                filter.Kind       = TokenMatchKind.Contains;
                filter.FilterExpr = expr.Trim('*');
            }
            else if (expr.EndsWith("*"))
            {
                filter.Kind       = TokenMatchKind.StartsWith;
                filter.FilterExpr = expr.TrimEnd('*');
            }
            else if (expr.StartsWith("*"))
            {
                filter.Kind       = TokenMatchKind.EndsWith;
                filter.FilterExpr = expr.TrimStart('*');
            }
            else if (expr.StartsWith("[") && expr.EndsWith("]"))
            {
                filter.Kind       = TokenMatchKind.Regex;
                filter.FilterExpr = expr.Trim("[]".ToCharArray());
            }
            else if (Regex.IsMatch(expr, @"\{\d+\}"))
            {
                filter.Kind       = TokenMatchKind.Expression;
                filter.FilterExpr = expr;
            }
            else
            {
                filter.Kind       = TokenMatchKind.Equals;
                filter.FilterExpr = expr;
            }
            return(filter);
        }
 private TokenFilter getFilter(XmlNode n, bool allow_implied)
 {
     TokenFilter filter = new TokenFilter();
     if (n.Attributes["target"] != null)
         filter.Target = n.Attributes["target"].Value == "sorting" ? TokenMatchTarget.Sorting : n.Attributes["target"].Value == "filtering" ? TokenMatchTarget.Filtering : TokenMatchTarget.All;
     filter.IsAllowed = n.Attributes["allowed"] == null ? !allow_implied : n.Attributes["allowed"].Value.ToLower() == "true" ? true : false;
     filter.IsCaseSensitive = n.Attributes["case-sensitive"] != null && n.Attributes["case-sensitive"].Value.ToLower() == "true";
     string expr = n.Attributes["expr"].Value.Trim();
     if (expr.StartsWith("*") && expr.EndsWith("*"))
     {
         filter.Kind = TokenMatchKind.Contains;
         filter.FilterExpr = expr.Trim('*');
     }
     else if (expr.EndsWith("*"))
     {
         filter.Kind = TokenMatchKind.StartsWith;
         filter.FilterExpr = expr.TrimEnd('*');
     }
     else if (expr.StartsWith("*"))
     {
         filter.Kind = TokenMatchKind.EndsWith;
         filter.FilterExpr = expr.TrimStart('*');
     }
     else if (expr.StartsWith("[") && expr.EndsWith("]"))
     {
         filter.Kind = TokenMatchKind.Regex;
         filter.FilterExpr = expr.Trim("[]".ToCharArray());
     }
     else if (Regex.IsMatch(expr, @"\{\d+\}"))
     {
         filter.Kind = TokenMatchKind.Expression;
         filter.FilterExpr = expr;
     }
     else
     {
         filter.Kind = TokenMatchKind.Equals;
         filter.FilterExpr = expr;
     }
     return filter;
 }