static void Main(string[] args) { NatashaInitializer.Initialize(false); string text = @"namespace HelloWorld { public class Test { public Test(){ Name=""111""; } public string Name; public int Age{get;set;} } }"; //根据脚本创建动态类 AssemblyCSharpBuilder oop = new AssemblyCSharpBuilder("test"); oop.Domain = DomainManagement.Random; oop.Domain.AddReferencesFromDllFile(typeof(object).Assembly.Location); oop.Add(text); Type type = oop.GetTypeFromShortName("Test"); Console.WriteLine(type.Name); var action = NDelegate.UseDomain(oop.Domain).Action(""); var a = action.Method; Console.WriteLine(action.Method.Module.Assembly); Console.WriteLine(DomainManagement.IsDeleted(action.GetDomain().Name)); Console.ReadKey(); }
static CSharpScriptEngine() { try { NatashaInitializer.Initialize() .ConfigureAwait(false).GetAwaiter().GetResult(); } catch (Exception ex) { InvokeHelper.OnInvokeException?.Invoke(ex); } }
static void Main(string[] args) { NatashaInitializer.Initialize(); string text = @"namespace HelloWorld { public class Test { public Test(){ Name=""111""; } public string Name; public int Age{get;set;} } }"; //根据脚本创建动态类 AssemblyCSharpBuilder oop = new AssemblyCSharpBuilder("test"); oop.Domain = DomainManagement.Random; //oop.Domain.AddReferencesFromDllFile(typeof(object).Assembly.Location); oop.Add(text); Type type = oop.GetTypeFromShortName("Test"); Console.WriteLine(type.Name); var action = NDelegate.UseDomain(oop.Domain).Action(""); var a = action.Method; Console.WriteLine(action.Method.Module.Assembly); Console.WriteLine(DomainManagement.IsDeleted(action.GetDomain().Name)); //var nClass = NClass // .RandomDomain(); //nClass.DelegateHandler. //type = NClass // .RandomDomain().Namespace("") // .Name("Test") // .Ctor(item => item // .Public() // .Body("Name = null;") // ) // .PublicField<string>("Name") // .GetType(); //type.Assembly //CSharpScript.EvaluateAsync Console.ReadKey(); }
static PrepareTest() { NatashaInitializer.Initialize(); }
static CSharpScriptEngine() { NatashaInitializer.Initialize(); }