Example #1
0
        static void Main(string[] args)
        {
            string text = @"namespace HelloWorld
{
    public class Test
    {
        public Test(){
            Name=""111"";
        }

        public string Name;
        public int Age{get;set;}
    }
}";
            //根据脚本创建动态类
            AssemblyCompiler oop = new AssemblyCompiler("test");

            oop.Add(text);
            Type type = oop.GetType("Test");

            Console.WriteLine(type.Name);

            var action = NDelegate.Random().Action("");
            var a      = action.Method;

            Console.WriteLine(action.Method.Module.Assembly);


            Console.ReadKey();
        }
Example #2
0
        public static void RunClassName1()
        {
            //ScriptCompiler.Init();
            string text = @"using System;
using System.Collections;
using System.Linq;
using System.Text;
 
namespace HelloWorld
{
    public class TestIndex1
    {
        public string Name;
        public int Age{get;set;}
    }
    public class TestIndex2
    {
        public string Name;
        public int Age{get;set;}
    }

    public class TestIndex3
    {
        public string Name;
        public int Age{get;set;}
    }
}

namespace HelloWorld{
    public struct TestStruct1{}
    public struct TestStruct2{}
    public class TestIndex4
    {
        public string Name;
        public int Age{get;set;}
    }
}

";
            //根据脚本创建动态类
            AssemblyCompiler oop = new AssemblyCompiler();

            oop.Add(text);
            Type type = oop.GetType("TestIndex3");

            Assert.Equal("TestIndex3", type.Name);
        }
Example #3
0
        public static void RunClassName0()
        {
            //ScriptCompiler.Init();
            string text = @"
namespace HelloWorld
{public class Test{public Test(){
            Name=""111"";
        }public string Name;
        public int Age{get;set;}
    }
}";
            //根据脚本创建动态类
            AssemblyCompiler oop = new AssemblyCompiler();

            oop.Add(text);
            Type type = oop.GetType("Test");

            Assert.Equal("Test", type.Name);
        }