Beispiel #1
0
    public void TestKnownProperty()
    {
        evaluator.Properties["Property"] = "Value";

        UnityELExpression <string> expression = evaluator.Compile <string>("Property");

        string result = expression.Evaluate(evaluator);

        Assert.AreEqual("Value", result);
    }
    public UnityELExpression <T> CreateExpression <T>(string expression)
    {
        evaluator = new UnityELEvaluator();
        evaluator.Properties["emptyString"] = "";
        evaluator.Properties["string"]      = "abc";
        evaluator.Properties["emptyArray"]  = new string[0];
        evaluator.Properties["array"]       = new string[] { "abc" };
        evaluator.Properties["emptyList"]   = new List <string>();
        evaluator.Properties["list"]        = new List <string> {
            "abc"
        };
        evaluator.Properties["emptyDictionary"] = new Dictionary <string, string>();
        evaluator.Properties["dictionary"]      = new Dictionary <string, string> {
            { "abc", "123" }
        };
        evaluator.Properties["emptySet"] = new HashSet <string>();
        evaluator.Properties["set"]      = new HashSet <string> {
            "abc"
        };
        evaluator.Properties["emptyEnumerable"] = new TestObject(false);
        evaluator.Properties["enumerable"]      = new TestObject(true);
        evaluator.Properties["emptyOther"]      = null;
        evaluator.Properties["other"]           = new OtherObject();

        return(evaluator.Compile <T>(expression));
    }
    private UnityELExpression <T> CreateExpression <T>(string expression)
    {
        evaluator = new UnityELEvaluator();

        stringDictionary = new Dictionary <string, string>();
        evaluator.Properties["stringDictionary"] = stringDictionary;

        stringList = new List <string>();
        evaluator.Properties["stringList"] = stringList;

        stringArray = new string[1];
        evaluator.Properties["stringArray"] = stringArray;

        intDictionary = new Dictionary <int, int>();
        evaluator.Properties["intDictionary"] = intDictionary;

        intList = new List <int>();
        evaluator.Properties["intList"] = intList;

        intArray = new int[1];
        evaluator.Properties["intArray"] = intArray;

        testObject = new TestObject();
        evaluator.Properties["testObject"] = testObject;

        return(evaluator.Compile <T>(expression));
    }
    public UnityELExpression <T> CreateExpression <T>(string expression)
    {
        evaluator = new UnityELEvaluator();
        evaluator.ArgumentGroupEvaluator  = new TestArgumentGroupEvaluator();
        evaluator.DefaultFunctionResolver = new TestFunctionResolver();

        return(evaluator.Compile <T>(expression));
    }
Beispiel #5
0
    public UnityELExpression <T> CreateExpression <T>(string expression)
    {
        evaluator = new UnityELEvaluator();
        evaluator.Properties["testObject"]   = new TestObject();
        evaluator.Properties["nullProperty"] = null;

        return(evaluator.Compile <T>(expression));
    }
    public UnityELExpression <T> CreateExpression <T>(string expression)
    {
        evaluator = new UnityELEvaluator();
        evaluator.Properties["nullLHS"]    = null;
        evaluator.Properties["nonNullLHS"] = true;
        evaluator.Properties["nullRHS"]    = null;
        evaluator.Properties["nonNullRHS"] = false;

        return(evaluator.Compile <T>(expression));
    }
    public UnityELExpression <T> CreateExpression <T>(string expression)
    {
        evaluator = new UnityELEvaluator();
        evaluator.Properties["property"]   = "anc";
        evaluator.Properties["dictionary"] = new Dictionary <string, string> {
            { "key", "value" }
        };
        evaluator.Properties["list"] = new List <string> {
            "abc"
        };
        evaluator.Properties["array"]  = new string[] { "abc" };
        evaluator.Properties["object"] = new TestObject();

        return(evaluator.Compile <T>(expression));
    }
    private UnityELExpression <T> CreateExpression <T>(string expression)
    {
        evaluator = new UnityELEvaluator();
        evaluator.Properties["a"] = 10;

        dictionary      = new Dictionary <string, int>();
        dictionary["a"] = 10;
        evaluator.Properties["dictionary"] = dictionary;

        list = new List <int>();
        list.Add(10);
        evaluator.Properties["list"] = list;

        array    = new int[2];
        array[0] = 10;
        evaluator.Properties["array"] = array;

        testObject          = new TestObject();
        testObject.Property = 10;

        evaluator.Properties["testObject"] = testObject;

        return(evaluator.Compile <T>(expression));
    }
 public UnityELExpression <T> CreateExpression <T>(string expression)
 {
     evaluator = new UnityELEvaluator();
     return(evaluator.Compile <T>(expression));
 }