XAMLのDynamic Load 13

Silverlight2.0上でIronPythonのプログラムをダウンロードし、実行する例。
生成される.xapにはIronPythonのdllも含まれるので、MACでも動作するのか?


using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Net;
using System.Net.Sockets;

using IronPython.Compiler;
using IronPython.Hosting;
using IronPython.Runtime;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;

namespace SilverlightApplication1
{
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();

m_engine = PythonEngine.CurrentEngine;
}

ScriptEngine m_engine;

private void OnClick1(object sender, RoutedEventArgs e)
{
WebClient wc = new WebClient();
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
wc.DownloadStringAsync( new Uri("http://localhost:49632/test.py"));
}
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
string src = e.Result;

SourceUnit source = m_engine.CreateScriptSourceFromString(src, SourceCodeKind.Statements );
IScriptScope m = PythonEngine.CurrentEngine.CreateScope();
m.SetVariable( "Page", this );
m_engine.Execute( m, source );
}

49632はデバッグでたまたま割り当てられたポート番号。(Uri svcUri = new Uri(System.Windows.Browser.HtmlPage.Document.DocumentUri, "test.py");)