Esempio n. 1
0
 private void Clear_Click(object sender, EventArgs e)
 {
     if (Filter.Checked)
     {
         SetFilters.Clear();
         SetFilters_LostFocus(sender, e);
     }
 }
        private void GetFilterSection(SetFilters setFilters, StringBuilder sb)
        {
            for (int i = 0; i < setFilters.Filters.Length; i++)
            {
                var filter = setFilters.Filters[i];
                sb.Append(@"
                " + (i > 0 ? "else " : "") + @"if (");
                switch (filter.Target)
                {
                case TokenMatchTarget.Sorting:
                    sb.Append("!isquery && (");
                    break;

                case TokenMatchTarget.Filtering:
                    sb.Append("isquery && (");
                    break;
                }
                switch (filter.Kind)
                {
                case TokenMatchKind.Equals:
                    if (!filter.IsCaseSensitive)
                    {
                        sb.Append("tk.TkName.toLowerCase() == '" + filter.FilterExpr + "'.toLowerCase()");
                    }
                    else
                    {
                        sb.Append("tk.TkName. == '" + filter.FilterExpr + "'");
                    }
                    break;

                case TokenMatchKind.Contains:
                    if (!filter.IsCaseSensitive)
                    {
                        sb.Append("tk.TkName.toLowerCase().indexOf('" + filter.FilterExpr + "'.toLowerCase()) != -1");
                    }
                    else
                    {
                        sb.Append("tk.TkName.indexOf('" + filter.FilterExpr + "') != -1");
                    }
                    break;

                case TokenMatchKind.StartsWith:
                    if (!filter.IsCaseSensitive)
                    {
                        sb.Append("tk.TkName.toLowerCase().indexOf('" + filter.FilterExpr + "'.toLowerCase()) == 0");
                    }
                    else
                    {
                        sb.Append("tk.TkName.indexOf('" + filter.FilterExpr + "') == 0");
                    }
                    break;

                case TokenMatchKind.EndsWith:
                    if (!filter.IsCaseSensitive)
                    {
                        sb.Append("tk.TkName.length >= '" + filter.FilterExpr + "'.length && tk.TkName.toLowerCase().indexOf('" + filter.FilterExpr + "'.toLowerCase()) == tk.TkName.length - '" + filter.FilterExpr + "'.length");
                    }
                    else
                    {
                        sb.Append("tk.TkName.length >= '" + filter.FilterExpr + "'.length && tk.TkName.indexOf('" + filter.FilterExpr + "') == tk.TkName.length - '" + filter.FilterExpr + "'.length");
                    }
                    break;

                case TokenMatchKind.Expression:
                    sb.Append(string.Format(filter.FilterExpr, "tk.TkName"));
                    break;

                case TokenMatchKind.Regex:
                    sb.Append("tk.TkName.match(" + filter.FilterExpr + ")");
                    break;
                }
                switch (filter.Target)
                {
                case TokenMatchTarget.Sorting:
                case TokenMatchTarget.Filtering:
                    sb.Append(")");
                    break;
                }
                sb.Append(@")
                    return " + (filter.IsAllowed ? "true" : "false") + @";");
            }
            sb.Append(@"
                else
                    return " + (setFilters.AllowImplied ? "true" : "false") + @";");
        }
Esempio n. 3
0
 private void Awake()
 {
     instanceObject = gameObject.GetComponentInChildren <SetFilters>();
 }
Esempio n. 4
0
 /// <summary>
 /// Adds set filter
 /// </summary>
 /// <param name="setCode"></param>
 /// <returns></returns>
 public SearchFilter AddSetFilter(string setCode)
 {
     SetFilters.Add(setCode);
     return(this);
 }