Esempio n. 1
0
        public void CheckScript()
        {
            IScriptEngineProvider scriptEngineProvider = new ScriptEngineProvider();
            DynamicScript         script = new DynamicScript();

            script.TenantId    = 0;
            script.Language    = DynamicScriptLanguage.CSharp;
            script.ProjectName = "TestApp";
            script.Script      =
                @"
using System;

//EndUsing

public int GetA(int a)
{
    return a;int 
}
";
            script.FunctionName = "GetA";
            script.Parameters   = new object[] { 111 };

            var result = scriptEngineProvider.CheckScript(script);

            Assert.False(result.IsSuccess);
        }
Esempio n. 2
0
        public void Reference()
        {
            IScriptEngineProvider scriptEngineProvider = new ScriptEngineProvider();
            DynamicScript         script = new DynamicScript();

            script.TenantId    = 0;
            script.Language    = DynamicScriptLanguage.CSharp;
            script.ProjectName = "TestApp";
            script.Script      =
                @"
using System;
using Newtonsoft.Json;

//EndUsing

public string GetA(int a)
{
    var b = JsonConvert.SerializeObject(a);
    return b;
}
";
            script.FunctionName = "GetA";
            script.Parameters   = new object[] { 111 };
            var result = scriptEngineProvider.RunScript <object>(script);
        }
Esempio n. 3
0
        public void Test1()
        {
            IScriptEngineProvider scriptEngineProvider = new ScriptEngineProvider();

            DynamicScript script = new DynamicScript();

            script.TenantId    = 0;
            script.Language    = DynamicScriptLanguage.CSharp;
            script.ProjectName = "TestApp";
            script.Script      =
                @"
using System;

//EndUsing

public int GetA(int a)
{
    return a;
}
";
            script.FunctionName = "GetA";
            script.Parameters   = new object[] { 111 };

            for (int i = 0; i < 10000; i++)
            {
                var result = scriptEngineProvider.RunScript <int>(script);
            }

            script.Script =
                @"
using System;

//EndUsing

public int GetB(int a)
{
    return a;
}
";
            script.FunctionName = "GetB";
            script.Parameters   = new object[] { 99999999 };

            for (int i = 0; i < 10000; i++)
            {
                var result = scriptEngineProvider.RunScript <int>(script);
            }
        }