Ejemplo n.º 1
0
        public static void test6()
        {
            try
            {
                ScriptEngine engine = Python.CreateEngine();
                var          paths  = engine.GetSearchPaths();
                paths.Add(@"D:\Program Files (x86)\IronPython 2.7\Lib");
                engine.SetSearchPaths(paths);
                ScriptScope scope = engine.CreateScope();

                ScriptSource script = engine.CreateScriptSourceFromFile(@"main3.py");
                var          result = script.Execute(scope);

                excel_cell_data cell_Data = new excel_cell_data();
                cell_Data.Int32Value = 200;
                cell_Data.Int64Value = 300;

                List <string> list = new List <string>();
                list.Add("1111");
                list.Add("2222");
                string[] list2 = { "aaaa", "bbbb" };
                var      func  = scope.GetVariable <Func <object, object> >("Test2");
                IronPython.Runtime.Bytes data = new IronPython.Runtime.Bytes(cell_Data.ToByteArray());
                func(data);


                var func2 = scope.GetVariable <Func <object> >("Test3");
                func2();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 2
0
 public void Foo(IronPython.Runtime.Bytes bytes)
 {
     Console.WriteLine("Foo:Bytes says hello");
     var bytes2 = bytes.ToByteArray();
 }