Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- using Microsoft.Scripting;
- using Microsoft.Scripting.Hosting;
- using IronRuby;
- // Add references to: IronRuby.dll, IronRuby.Libraries.dll,
- // Microsoft.Scripting.dll, and Microsoft.Scripting.Core.dll
- namespace IronRubyEmbedDemo
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- //Set the title of the form
- this.Text = "Hello World!";
- //Create the iron ruby engine
- ScriptEngine engine = IronRuby.Ruby.CreateEngine();
- ScriptScope scope = engine.CreateScope();
- //Set this form as the variable "form" in the engine
- scope.SetVariable("form", this);
- //Create a line of code to execute in the engine
- String code = "form.Text";
- //Execute the code
- ScriptSource script = engine.CreateScriptSourceFromString(code, SourceCodeKind.SingleStatement);
- Object result = script.Execute(scope);
- //Display the result
- MessageBox.Show(result.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement