public void TestCall1() { //ScriptComplier.Init(); string text = @"using System; using System.Collections; using System.Linq; using System.Text; namespace HelloWorld { public class Test { public Test(){ Name=""111""; } public string Name; public int Age{get;set;} } }"; //根据脚本创建动态类 Type type = ClassBuilder.GetType(text); //创建动态类实例代理 DynamicOperatorBase instance = DynamicOperator.GetOperator(type); //Get动态调用 Assert.Equal("111", instance["Name"].StringValue); //调用动态委托赋值 instance["Name"].StringValue = "222"; Assert.Equal("222", instance["Name"].StringValue); }
public void Preheating() { OriginModel = new CallModel(); EmitModel = new CallModel(); NatashaModel = new CallModel(); NatashaProxyModel = new CallModel(); NatashaCaller = new DynamicOperator <CallModel>(); DynamicObjectCaller = new DynamicOperator(typeof(CallModel)); DynamicStrongCaller = DynamicOperator.GetOperator(typeof(CallModel)); }