using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IronPython.Hosting;
using System.IO;

namespace MyIPY
{
    class Program
    {
        static void Main(string[] args)
        {
            //启动ironpython并获取脚本文件对象
            var python = Python.CreateRuntime();
            File.WriteAllText("script/1.py", "A=[1,2,3,4]", Encoding.UTF8);

            dynamic script1 = python.UseFile(AppDomain.CurrentDomain.BaseDirectory + "script/1.py");
            var U= script1.A;
            for (int i = 0; i < 200000; i++)
            {
                dynamic script = python.UseFile(AppDomain.CurrentDomain.BaseDirectory + "test.py");
                //调用Python里的类
                var service = script.MyService();
                string result = service.GetData("11");
                Console.WriteLine(result);

                //调用文件中的函数
                result = script.MyFunction("fff");
                IronPython.Runtime.List result1 = script.AAA;
                IronPython.Runtime.PythonDictionary result2 = script.BBB;
                Console.WriteLine(result);
            }
            do
            {
                Console.ReadLine();

            } while (true);
        }
    }
}
