Created
December 14, 2009 03:53
-
-
Save jschementi/255762 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Action eachFrame = null; | |
_scope.TryGetVariable<Action>("each_frame", out eachFrame); | |
EachFrame = eachFrame; | |
Func<object, dynamic> eachObject = null; | |
_scope.TryGetVariable<Func<object, dynamic>>("each_object", out eachObject); | |
EachObject = eachObject; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CaptureAnimationCallbacks(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime.LoadAssembly(typeof(Canvas).Assembly); // loads PresentationFramework | |
runtime.LoadAssembly(typeof(Brushes).Assembly); // loads PresentationCore | |
runtime.LoadAssembly(GetType().Assembly); // loads this exe | |
_scope.canvas = _canvas; | |
_scope.window = this; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ScriptEngine _rubyEngine; | |
private IronRuby.Runtime.RubyContext _rubyContext; | |
private dynamic _scope; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize IronRuby | |
var runtime = ScriptRuntime.CreateFromConfiguration(); | |
_rubyEngine = Ruby.GetEngine(runtime); | |
_rubyContext = Ruby.GetExecutionContext(_rubyEngine); | |
_scope = _rubyEngine.CreateScope(); | |
// redirect stdout to the output window | |
_rubyContext.StandardOutput = OutputBuffer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RegisterCallbacks(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run the code | |
var result = _rubyEngine.Execute(code, _scope); | |
// write the result to the output window | |
var output = string.Format("=> {0}\n", _rubyContext.Inspect(result)); | |
OutputBuffer.write(output); | |
// add the code to the history | |
_history.AppendText(string.Format("{0}\n{1}", code, output)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Scripting.Hosting; | |
using IronRuby; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment