using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom;
using System.Xml.Linq;
using DynamicCompiler;

namespace ConsoleApplication5
{
    class Program
    {
        const string functionIndentSpace = "\t\t\t";
        static void Main(string[] args)
        {
            XElement f1parameter = new XElement("Parameters",
                new XElement("Parameter",
                new XElement("Type", "System.String"),
                new XElement("ParameterName", "inputMessage")),
                new XElement("Parameter",
                new XElement("Type", "System.Int32"),
                new XElement("ParameterName", "inputInt"))
                );
            
            FunctionScript f1 = new FunctionScript() 
            { 
                ClassName = "MyClass", 
                ClassNameSpace = "My", 
                FunctionName = "hello",
                ReturnType="System.String",
                Parameters=f1parameter,
                ScriptBody = functionIndentSpace+"return \"hello\"+inputInt.ToString();" 
            };
            FunctionScript f2 = new FunctionScript()
            {
                ClassName = "MyClass",
                ClassNameSpace = "My",
                FunctionName = "hello1",
                ScriptBody = functionIndentSpace + "Console.WriteLine(hello(\"x\",1));"
            };
            List<FunctionScript> list=new List<FunctionScript>();
            list.Add(f1);
            list.Add(f2);
            CodeBuilder c = new CodeBuilder(list);
            Console.WriteLine(c.GenerateCode());
            Compiler pc = new Compiler();
            pc.Compile(c.GenerateCode(), "x.dll");

            Executor ex = new Executor("x.dll", "My.MyClass", "hello1");
            ex.Execute();

        }
    }
}
