Esempio n. 1
0
        public List <CondGroup> Parse()
        {
            childCondStrings.Clear();
            string           escapeedCode     = "AND " + Regex.Replace(code, @"\((.*?)\)", ReplaceByPlaceholder);
            Regex            regex            = new Regex(@"(AND|OR)\s+(\S+)\s+(\S+)\s+(\S+)\s*");
            Regex            placeHolderRegex = new Regex(@"^(AND|OR)\s+" + PLACEHOLDER);
            List <CondGroup> condGroups       = new List <CondGroup>();
            MatchCollection  mc  = regex.Matches(escapeedCode);
            int placeHolderIndex = 0;

            foreach (Match m in mc)
            {
                CondGroup condGroup = new CondGroup();
                condGroups.Add(condGroup);
                condGroup.Connector = m.Groups[1].Value;
                if (placeHolderRegex.IsMatch(m.Groups[0].Value))
                {
                    string          childCode            = "OR " + childCondStrings[placeHolderIndex++];
                    MatchCollection childMatchCollection = regex.Matches(childCode);
                    foreach (Match childMatch in childMatchCollection)
                    {
                        Cond cond = new Cond();
                        condGroup.Conds.Add(cond);
                        cond.Connector  = childMatch.Groups[1].Value;
                        cond.LeftValue  = childMatch.Groups[2].Value;
                        cond.Operator   = childMatch.Groups[3].Value;
                        cond.RightValue = childMatch.Groups[4].Value;
                    }
                }
                else
                {
                    Cond cond = new Cond();
                    condGroup.Conds.Add(cond);
                    cond.LeftValue  = m.Groups[2].Value;
                    cond.Operator   = m.Groups[3].Value;
                    cond.RightValue = m.Groups[4].Value;
                }
            }
            return(condGroups);
        }
Esempio n. 2
0
 public void DownCond()
 {
     CondGroup.DownCond(this);
 }
Esempio n. 3
0
 public void UpCond()
 {
     CondGroup.UpCond(this);
 }
Esempio n. 4
0
 public void RemoveCond()
 {
     CondGroup.RemoveCond(this);
 }
Esempio n. 5
0
 public void AddCond()
 {
     CondGroup.AddCond(this);
 }
Esempio n. 6
0
 public List<CondGroup> Parse()
 {
     childCondStrings.Clear();
     string escapeedCode = "AND " + Regex.Replace(code, @"\((.*?)\)", ReplaceByPlaceholder);
     Regex regex = new Regex(@"(AND|OR)\s+(\S+)\s+(\S+)\s+(\S+)\s*");
     Regex placeHolderRegex = new Regex(@"^(AND|OR)\s+" + PLACEHOLDER);
     List<CondGroup> condGroups = new List<CondGroup>();
     MatchCollection mc = regex.Matches(escapeedCode);
     int placeHolderIndex = 0;
     foreach (Match m in mc)
     {
         CondGroup condGroup = new CondGroup();
         condGroups.Add(condGroup);
         condGroup.Connector = m.Groups[1].Value;
         if (placeHolderRegex.IsMatch(m.Groups[0].Value))
         {
             string childCode = "OR " + childCondStrings[placeHolderIndex++];
             MatchCollection childMatchCollection = regex.Matches(childCode);
             foreach (Match childMatch in childMatchCollection)
             {
                 Cond cond = new Cond();
                 condGroup.Conds.Add(cond);
                 cond.Connector = childMatch.Groups[1].Value;
                 cond.LeftValue = childMatch.Groups[2].Value;
                 cond.Operator = childMatch.Groups[3].Value;
                 cond.RightValue = childMatch.Groups[4].Value;
             }
         }
         else
         {
             Cond cond = new Cond();
             condGroup.Conds.Add(cond);
             cond.LeftValue = m.Groups[2].Value;
             cond.Operator = m.Groups[3].Value;
             cond.RightValue = m.Groups[4].Value;
         }
     }
     return condGroups;
 }