Example #1
0
    public void LoadMethodTyped()
    {
        //ICalc script = CSScript.MonoEvaluator //as alternative syntax
        ICalc script = new MonoEvaluator()
                       .LoadMethod <ICalc>(@"using System;

                                                    public int Sum(int a, int b)
                                                    {
                                                        return sumImpl(a,b);
                                                    }

                                                    int sumImpl(int a, int b)
                                                    {
                                                        return a+b;
                                                    }");

        int result = script.Sum(1, 2);

        Assert.Equal(3, result);
    }
Example #2
0
    public void LoadMethodTyped()
    {
        //ICalc script = CSScript.MonoEvaluator //as alternative syntax
        ICalc script = new MonoEvaluator()
                               .LoadMethod<ICalc>(@"using System;

                                                    public int Sum(int a, int b)
                                                    {
                                                        return sumImpl(a,b);
                                                    }

                                                    int sumImpl(int a, int b)
                                                    {
                                                        return a+b;
                                                    }");

        int result = script.Sum(1, 2);

        Assert.Equal(3, result);
    }