Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using IronRuby;
- using IronRuby.Builtins;
- using Microsoft.Scripting.Hosting;
- // This sample targets the .NET 2.0 Framework, using IronRuby 1.0. If you are using IronRuby 1.1, it will be slightly different.
- // Make references to IronRuby.dll, IronRuby.Libraries.dll, Microsoft.Scripting.dll, and Micrsoft.Scripting.Core.dll
- // Although Microsoft.Dynamic.dll does not need referenced, it must be in the directory of the executing assembly
- namespace RubySample
- {
- public class SharpRubyForm
- {
- private ScriptEngine _engine;
- private ScriptScope _scope;
- private void InitializeRuby()
- {
- ScriptRuntime _runTime = Ruby.CreateRuntime();
- _engine = Ruby.GetEngine(_runTime);
- _scope = _engine.CreateScope();
- }
- private object LoadRubyObject(string path)
- {
- _scope.SetVariable("path", path);
- return _engine.Execute(@"
- file = File.open(path, 'rb')
- object = Marshal.load(file)
- file.close
- return object", _scope);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement