private void Initialize(string[] preloadedAssemblies = null) { CustomLoadedAssemblies = preloadedAssemblies; RobotoMono = FontFamily.Parse("resm:ScriptConsoleLibrary.Fonts.?assembly=ScriptConsoleLibrary#Roboto Mono"); GlobalsContainer.consoleContainer = this.FindControl <StackPanel>("consoleContainer"); GlobalsContainer._____ConsoleWriter = new OutputConsoleWriter(this.FindControl <StackPanel>("consoleContainer")); GlobalsContainer.Ans = null; GlobalsContainer.cSharpConsole = this; globalsContainer = new GlobalsContainer(); lastTask = CSharpScript.RunAsync("System.Console.SetOut(_____ConsoleWriter);", null, globalsContainer); lastTask.Wait(); foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { bool toBeLoaded = false; try { if (preloadedAssemblies == null) { if (CoreLoadedAssemblies.Contains(asm.GetName().Name)) { toBeLoaded = true; } } else { if (preloadedAssemblies.Contains(asm.GetName().Name)) { toBeLoaded = true; } } } catch { } if (toBeLoaded) { try { lastTask = lastTask.Result.ContinueWithAsync("#r \"" + asm.FullName + "\""); lastTask.Wait(); } catch { try { lastTask = lastTask.Result.ContinueWithAsync("#r \"" + asm.Location + "\""); lastTask.Wait(); } catch (Exception ex) { Exception reportedEx; try { reportedEx = new AssemblyLoadException("An error occurred while loading assembly " + asm.GetName().Name + ": its types will be available during structure exploration but not in code.", ex, asm); } catch { reportedEx = new AssemblyLoadException("An error occurred while loading an assembly.", ex, asm); } this.FindControl <StackPanel>("consoleContainer").Children.Insert(this.FindControl <StackPanel>("consoleContainer").Children.Count - 1, new ErrorLine(reportedEx, true)); } } } } }
private void ___Reset() { this.FindControl <StackPanel>("consoleContainer").Children.Clear(); this.FindControl <StackPanel>("consoleContainer").Children.Add(this.FindControl <ConsoleInputLine>("inputLine")); this.lastTask = null; GlobalsContainer.consoleContainer = this.FindControl <StackPanel>("consoleContainer"); GlobalsContainer._____ConsoleWriter = new OutputConsoleWriter(this.FindControl <StackPanel>("consoleContainer")); GlobalsContainer.Ans = null; GlobalsContainer.cSharpConsole = this; this.globalsContainer = new GlobalsContainer(); this.lastTask = CSharpScript.RunAsync("System.Console.SetOut(_____ConsoleWriter);", null, this.globalsContainer); this.lastTask.Wait(); foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { bool toBeLoaded = false; try { if (CustomLoadedAssemblies == null) { if (CoreLoadedAssemblies.Contains(asm.GetName().Name)) { toBeLoaded = true; } } else { if (CustomLoadedAssemblies.Contains(asm.GetName().Name)) { toBeLoaded = true; } } } catch { } if (toBeLoaded) { try { this.lastTask = this.lastTask.Result.ContinueWithAsync("#r \"" + asm.FullName + "\""); this.lastTask.Wait(); } catch { try { this.lastTask = this.lastTask.Result.ContinueWithAsync("#r \"" + asm.Location + "\""); this.lastTask.Wait(); } catch (Exception ex) { Exception reportedEx; try { reportedEx = new AssemblyLoadException("An error occurred while loading assembly " + asm.GetName().Name + ": its types will be available during structure exploration but not in code.", ex, asm); } catch { reportedEx = new AssemblyLoadException("An error occurred while loading an assembly.", ex, asm); } this.FindControl <StackPanel>("consoleContainer").Children.Insert(this.FindControl <StackPanel>("consoleContainer").Children.Count - 1, new ErrorLine(reportedEx, true)); } } } } this.history.Clear(); }