Exemplo n.º 1
0
    string CustomCondition(string param)
    {
        param = param.Trim();
        if (string.IsNullOrEmpty(param))
        {
            return("parameters needed");
        }
        string[] ss        = param.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
        string   classname = ss[0];

        ScenarioRTL.Condition       cdt = ScenarioRTL.Asm.CreateConditionInstance(classname);
        ScenarioRTL.IO.StatementRaw raw = new ScenarioRTL.IO.StatementRaw();

        if (cdt == null)
        {
            return("cannot create statement");
        }

        raw.classname  = classname;
        raw.order      = 0;
        raw.parameters = new ScenarioRTL.IO.ParamRaw(ss.Length - 1);
        for (int i = 1; i < ss.Length; ++i)
        {
            string   paramstr = ss[i];
            string[] nv       = paramstr.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
            if (nv.Length == 2)
            {
                raw.parameters.Set(i - 1, nv[0], nv[1]);
            }
            else
            {
                raw.parameters.Set(i - 1, "null", "0");
            }
        }
        cdt.Init(null, raw);

        bool?check = cdt.Check();

        return("[" + classname + "] check result is " + check.ToString());
    }