public MainWindow() { Thread.CurrentThread.Name = "UI Thread"; InitializeComponent(); InitializeHighlighters(); txtSource.CurrentHighlighter = HighlighterManager.Instance.Highlighters["CSharp"]; inputAggregator = new InputAggregator(); virtualConsoleController = new VirtualConsoleController(txtConsoleOut, inputAggregator); DataContext = new MainWindowsViewModel(inputAggregator); var dp = DependencyPropertyDescriptor.FromProperty(TextBlock.TextProperty, typeof(TextBlock)); dp.AddValueChanged(txtConsoleOut, (sender, args) => { consoleScroller.ScrollToBottom(); }); //ConsoleOutputWriter outputRedirector = new ConsoleOutputWriter(txtConsoleOut); //ConsoleInputReader inputRedirector = new ConsoleInputReader(txtConsoleOut); //Console.SetOut(outputRedirector); //Console.SetIn(inputRedirector); }
public override void LoadAndRun(byte[] assemblyBytes, InputAggregator inputAggregator) { try { this.Instance.LoadAndRun(assemblyBytes, inputAggregator); } catch (Exception ex) { throw; } }
public VirtualConsoleController(TextBox consolebox, InputAggregator inputaggregator) { consoleBox = consolebox; inputAggregator = inputaggregator; inputaggregator.WaitForUserInput += Inputaggregator_WaitForUserInput; inputaggregator.EndWaitForUserInput += Inputaggregator_EndWaitForUserInput; DisableInput = true; consoleBox.PreviewTextInput += ConsoleBox_PreviewTextInput; consoleBox.PreviewKeyDown += ConsoleBox_PreviewKeyDown; consoleBox.SelectionChanged += ConsoleBox_SelectionChanged; }
public MainWindowsViewModel(InputAggregator inputaggregator) { inputAggregator = inputaggregator; string netstandardRefsDirectory = Path.Combine(new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.Parent.Parent.FullName, "libs", "netstandard2.0"); compiler = new Compiler(netstandardRefsDirectory); runThread = null; SourceCode = @"using System; namespace Test { public class Program { public static void Main(string[] args) { Console.Write(""What is your name ? ""); //char input = (char)Console.Read(); string input = Console.ReadLine(); Console.WriteLine($""Hello { input }""); } } }"; consoleOutput = @"============================================ .NET Framework C# REPL by Sigged ============================================ 1. Enter C# code in the editor on the right 2. Press Build and Run 3. Watch Roslyn in action! ============================================ Ready. "; }
public virtual void LoadAndRun(byte[] assemblyBytes, InputAggregator inputAggregator) { try { CrossDomainConsoleOutputWriter outputRedirector = new CrossDomainConsoleOutputWriter(); outputRedirector.OnConsoleOutput += OutputRedirector_OnConsoleOutput; CrossDomainConsoleInputReader inputRedirector = new CrossDomainConsoleInputReader(inputAggregator); Console.SetOut(outputRedirector); Console.SetIn(inputRedirector); var assembly = AppDomain.CurrentDomain.Load(assemblyBytes); //invoke main method var mainParms = assembly.EntryPoint.GetParameters(); if (mainParms.Count() == 0) { assembly.EntryPoint.Invoke(null, null); } else { if (mainParms[0].ParameterType == typeof(string[])) { assembly.EntryPoint.Invoke(null, new string[] { null }); } else { assembly.EntryPoint.Invoke(null, null); } } } catch (Exception ex) { throw; } }
public CrossDomainConsoleInputReader(InputAggregator inputaggregator) { inputAggregator = inputaggregator; }
public AssemblyLoaderProxy(AssemblyLoader loaderInstance, InputAggregator inputaggregator) { inputAggregator = inputaggregator; Instance = loaderInstance; Instance.OnConsoleOutput += new ConsoleOutputHandler((sender, output) => RaiseOnConsoleOutput(Instance, output)); }