Example #1
0
        public FilterMatchCollection Matches()
        {
            FilterMatchCollection col = new FilterMatchCollection();

            foreach (FilterRule r1 in filters)
            {
                /*
                 * if (this.check_data.Select(r1.ToSqlString()).Length > 0)
                 *  col.AddMatch(new FilterMatch(true, r1));*/

                //Novo método
                if (r1.FilterGroups != null)
                {
                    String exp = "";

                    FilterSelector groupLastSelector = FilterSelector.OR;

                    foreach (FilterGroup g in r1.FilterGroups)
                    {
                        if (g.FilterRules != null)
                        {
                            String exp1 = "";

                            FilterSelector lastSelector = FilterSelector.AND;

                            foreach (FilterCondition f in g.FilterRules)
                            {
                                if (exp1 != "")
                                {
                                    exp1 += " " + lastSelector.ToString() + " ";
                                }
                                if (this.check_data.Select(f.ToSqlString()).Length > 0)
                                {
                                    exp1 += " true ";
                                }
                                else
                                {
                                    exp1 += " false ";
                                }

                                lastSelector = f.Selector;
                            }

                            if (exp != "" && exp1 != "")
                            {
                                exp += " " + groupLastSelector.ToString().ToLower() + " ";
                            }
                            exp += (exp1 != "" ? "(" : "") + exp1 + (exp1 != "" ? ")" : "");

                            groupLastSelector = g.Selector;
                        }
                    }

                    if (ExecExpression(exp))
                    {
                        col.AddMatch(new FilterMatch(true, r1));
                    }
                }
            }

            return(col);
        }
Example #2
0
 public FilterMatchEnumerator(FilterMatchCollection m)
 {
     this.m = m;
 }