async void Compile_Clicked(System.Object sender, System.EventArgs e) { try { Type type; Stopwatch sw = new Stopwatch(); sw.Start(); if (CSharpScript.IsChecked) { string code = CodeGenerator.GetCSharpScriptCode(Public.IsChecked, "Sample.Forms"); type = await CSharpScriptLoader.Load(code, "NewClass"); } else { string code = CodeGenerator.GetCSharpCompilationCode(Public.IsChecked); var assembly = Assembly.GetExecutingAssembly(); type = await CSharpCompilationLoader.Load(code, "CSharpClassReloading.NewClass"); } var executeMethod = type.GetMethod("Execute"); executeMethod.Invoke(null, null); Result.Text = ("Total Executed Time: " + sw.ElapsedMilliseconds); } catch (Exception ex) { } }
static async Task Main(string[] args) { Console.WriteLine("1. CSharpScript"); Console.WriteLine("2. CSharpCompilation"); var loadType = int.Parse(Console.ReadLine()); Console.WriteLine("1. Public Class"); Console.WriteLine("2. Internal Class"); var classType = int.Parse(Console.ReadLine()); Type type; try { Stopwatch sw = new Stopwatch(); sw.Start(); switch (loadType) { case (1): string code = CodeGenerator.GetCSharpScriptCode(classType == 1, "CSharpClassReloading.dll"); type = await CSharpScriptLoader.Load(code, "NewClass"); break; default: code = CodeGenerator.GetCSharpCompilationCode(classType == 1); type = await CSharpCompilationLoader.Load(code, "CSharpClassReloading.NewClass"); break; } var executeMethod = type.GetMethod("Execute"); executeMethod.Invoke(null, null); Console.WriteLine("Total Executed Time: " + sw.ElapsedMilliseconds); } catch (Exception ex) { Console.WriteLine(ex); } }