Skip to content

Instantly share code, notes, and snippets.

diff --git a/sketchscript/sketchscript/MainWindow.xaml.cs b/sketchscript/sketchscript/MainWindow.xaml.cs
index 22a01f3..8e62ff1 100644
--- a/sketchscript/sketchscript/MainWindow.xaml.cs
+++ b/sketchscript/sketchscript/MainWindow.xaml.cs
@@ -17,6 +17,8 @@ using System.IO;
using AeroGlass;
using System.Diagnostics;
using SThread = System.Threading;
+using Microsoft.Scripting.Hosting;
+using IronRuby;
class Bouncer
def initialize xvelocity, yvelocity, canvas
@xvelocity = xvelocity
@yvelocity = yvelocity
@canvas = canvas
end
def update target
if (Canvas.get_left(target) + @xvelocity) >= (@canvas.actual_width - target.width) or (Canvas.get_left(target) + @xvelocity) <= 0
@xvelocity = -@xvelocity
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;
// create a ScriptRuntime, the portal to the DLR Hosting API
// CreateFromConfiguration gets information, like languages
// are available, from an app.config configuration file
var runtime = ScriptRuntime.CreateFromConfiguration();
// create a ScriptEngine for IronRuby
var engine = runtime.GetEngine("IronRuby");
// a ScriptScope stores state between executions
var scope = engine.CreateScope();
<html>
<head>
<!-- one javascript block required to make Ruby work -->
<script type="text/javascript" src="http://mschnlnine.vo.llnwd.net/d1/dlr-20091120.js"></script>
</head>
<body>
<script type="text/ruby">
window.alert "Hello, World -- from Ruby"
</script>
</body>
import System # .NET System namespace
import foo # foo.py in the XAP
import bar.baz # bar/baz.py in the XAP
var setup = Silverlight.DynamicEngine.CreateRuntimeSetup();
var runtime = new Hosting.ScriptRuntime(setup);
using Silverlight = Microsoft.Scripting.Silverlight;
var runtime = Silverlight.DynamicEngine.CreateRuntime();
var python = runtime.GetEngine("python");
@jschementi
jschementi / dynamic_demo.cs
Created October 22, 2009 08:03
IronPython and C# 4 "dynamic"
using System;
using IronPython.Hosting;
public class dynamic_demo {
static void Main() {
var ipy = Python.CreateRuntime();
dynamic mock = ipy.UseFile("mock.py");
// Calls the Python Mock type's constructor
dynamic m = mock.Mock();
@jschementi
jschementi / dynamic_demo.cs
Created October 22, 2009 08:00
IronRuby and C# 4 "dynamic"
using System;
using IronRuby;
public class dynamic_demo {
static void Main() {
var rb = Ruby.CreateEngine();
rb.ExecuteFile("mock.rb");
dynamic globals = rb.Runtime.Globals;
// Call the Ruby "Mock" class constructor