Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 static CSharpScriptEngine()
 {
     try
     {
         NatashaInitializer.Initialize()
         .ConfigureAwait(false).GetAwaiter().GetResult();
     }
     catch (Exception ex)
     {
         InvokeHelper.OnInvokeException?.Invoke(ex);
     }
 }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
 static PrepareTest()
 {
     NatashaInitializer.Initialize();
 }
Esempio n. 5
0
 static CSharpScriptEngine()
 {
     NatashaInitializer.Initialize();
 }