CompileResult CompileCode () { var r = new CompileResult { Code = Code }; Console.WriteLine ("COMPILE!!!"); var idt = typeof(IDrawable); eval.ReferenceAssembly (idt.Assembly); eval.ReferenceAssembly (typeof(Platforms).Assembly); object res; bool resSet; eval.Evaluate (Code, out res, out resSet); var drawables = new List<IDrawable> (); if (errors.ToString ().Contains ("): error")) { r.Errors = errors.ToString (); } else { foreach (Match m in classRe.Matches (Code)) { var className = m.Groups [1].Value; eval.Evaluate ("new " + className + " ()", out res, out resSet); if (resSet) { var d = res as IDrawable; if (d != null) { drawables.Add (d); } } } r.Drawables = drawables.ToArray (); } return r; }
void AcceptCompileResult(CompileResult result) { this.BeginInvokeOnMainThread (() => { try { if (result.Code == Code) { Console.WriteLine ("NEW RESULT {0}", this.result); this.result = result; Errors.Value = result.Errors ?? ""; Errors.TextColor = NSColor.Red; if (string.IsNullOrEmpty (result.Errors)) { Prev.Drawables = result.Drawables; Prev.SetNeedsDisplayInRect (Prev.Bounds); } } } catch (Exception ex) { Console.WriteLine (ex); } }); }