Пример #1
0
		public void set_type(Type t) {
			Mirror m = new Mirror (t);
			label1.Text = t.ToString();
			_paths.AddRange(m.GetFlatLayout ());
			_paths.Sort ();
			for (int i = 0;i< _paths.Count;i++)
				combobox1.AppendText(_paths[i]);
		}
Пример #2
0
		public condition_view ()
		{
			this.Build ();
			Mirror m = new Mirror (typeof(http_request));
			_paths.AddRange(m.GetFlatLayout ());
			_paths.Sort ();
			for (int i = 0;i< _paths.Count;i++)
				combobox2.AppendText(_paths[i]);
		}
Пример #3
0
        public static Boolean Check(Object instance,String condition)
        {
            Boolean retval = false;
            Mirror m = new Mirror(instance.GetType());
            Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
			Boolean ors = false;
			String[] split = new string[]{condition}; 
			if(condition.Contains(" & "))
				split = condition.Split(new String[]{" & "}, StringSplitOptions.RemoveEmptyEntries);
			else if(condition.Contains(" | ")) {
				split = condition.Split(new String[]{" | "}, StringSplitOptions.RemoveEmptyEntries);
				ors = true;
			}
            foreach(String cond in split)
            {
                Match match = r.Match(cond);
                String op = match.Groups["Op"].Value.Trim();
                String criteria = match.Groups["Value"].Value.Trim();
                String target = match.Groups["Keyword"].Value.Trim();
                String testcase = m.GetStringProp(target, instance);

                decimal dtestcase;
                decimal dcriterial;

                if(testcase == null)
                    testcase = "";

                switch (op)
                {
                    case "=":
                        retval = (testcase.ToLower() == criteria.ToLower());
                        break;
                    case "!=":
                        retval = (testcase.ToLower() != criteria.ToLower());
                        break;
                    case "contains":
                        retval = (testcase.ToLower().Contains(criteria.ToLower()));
                        break;
                    case "startswith":
                        retval = (testcase.ToLower().StartsWith(criteria.ToLower()));
                        break;
                    case "endswith":
                        retval = (testcase.ToLower().EndsWith(criteria.ToLower()));
                        break;
                    case ">":                      
                        if(Decimal.TryParse(testcase,out dtestcase) & Decimal.TryParse(criteria,out dcriterial))
                        {
                            retval = dtestcase > dcriterial;
                        }
                        break;
                    case "<":
                        if (Decimal.TryParse(testcase, out dtestcase) & Decimal.TryParse(criteria, out dcriterial))
                        {
                            retval = dtestcase < dcriterial;
                        }
                        break;
                }

				if (!retval && !ors)
					break;
				else if (ors && retval)
					break;
            }
            return retval;
        }