Exemplo n.º 1
0
 public static bool IsMatch(string expression)
 {
     try
     {
         _compiler.SetFunction(expression);
         _compiler.Compile();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
    public static bool BoolValue(string aExpression, Dictionary <string, float> eParams)
    {
        aExpression = aExpression.Replace("?", ((int)Random.Range(0, 100)).ToString());
        EquationCompiler oCompiler = new EquationCompiler(aExpression);

        oCompiler.Compile();

        if (aExpression.Length > 8)
        {
            foreach (KeyValuePair <string, float> pair in eParams)
            {
                oCompiler.SetVariable(pair.Key, pair.Value);
            }
        }
        foreach (KeyValuePair <string, float> pair in eParams)
        {
            oCompiler.SetVariable(pair.Key, pair.Value);
        }
        return(oCompiler.Calculate() == 1);
    }