public void RunClassName4() { //ScriptCompiler.Init(); string text = @" namespace HelloWorld {public class Test{public Test(){ Name=""111""; }public string Name; public int Age{get;set;} } }"; //根据脚本创建动态类 var oop = new NAssembly(); oop.AssemblyBuilder.Compiler.Domain = DomainManagement.Random; oop.AddScript(text); Type type = oop.GetTypeFromShortName("Test"); Assert.Equal("Test", type.Name); }
public static void RunClassName4() { //ScriptCompiler.Init(); string text = @" namespace HelloWorld {public class Test{public Test(){ Name=""111""; }public string Name; public int Age{get;set;} } }"; //根据脚本创建动态类 var oop = new NAssembly(); oop.AddScript(text); oop.Compile(); Type type = oop.GetType("HelloWorld.Test"); Assert.Equal("Test", type.Name); }