Dynamic Silverlight
LasVegasのMIX08カンファレンスでDynamicSilverlightが紹介されたようです。
http://dynamicsilverlight.net/
DynamicSilverlightは、SilverlightとDynamicLanguageRuntime(DLR)を統合する技術。
DSLは、SKDと同様にランタイムで、以下の2つのassemblieから構成され
- Microsoft.Scripting.dll
- Microsoft.Scripting.Silverlight.dll
以下の言語アセンブリが必要です
- IronRuby.dll/IronRuby.Libraries.dll
- IronPython.dll/IronPython.Modules.dll
とにかくまず
Quickstart for using IronRuby, IronPython, or Managed JScriptとして
http://silverlight.net/Quickstarts/ProgramDlr.aspx
ここを見るのがいい。
説明として以下のような簡単なサンプルや
<UserControl xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="System.Windows.Controls.UserControl" x:Name="Page" > <TextBlock x:Name="TextBlock1" TextWrapping="Wrap" Foreground="Black" Text="Click Me." /> </UserControl>
jsx
Import("System.Windows.*"); Import("System.Windows.Controls.*"); xaml = Application.Current.LoadRootVisual(new UserControl(), 'app.xaml') xaml.TextBlock1.MouseLeftButtonUp += function (sender, args) { sender.FontSize *= 2 }
py
from System.Windows import Application from System.Windows.Controls import UserControl def OnClick (sender, args): sender.FontSize *= 2 scene = Application.Current.LoadRootVisual(UserControl(), 'app.xaml') scene.TextBlock1.MouseLeftButtonUp += OnClick
rb
include System::Windows include System::Windows::Controls scene = Application.current.load_root_visual UserControl.new, 'app.xaml' scene.find_name('TextBlock1').mouse_left_button_up do |sender, args| sender.font_size = sender.font_size * 2 end
以下のような説明があって分かりやすく説明されています。
To access Silverlight-based class libraries from IronPython
1.Use the import statement to load the clr module.
import clr
2.Use the clr.AddReference function to load assemblies and make their contents available for import.
clr.AddReference("MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089")
3.Use the import statement to add namespaces to the current context or to load modules. You must import namespaces before you can use them.
import System.Windows import System import MyPythonModule
4.Use the from … import statement to add the contents of a namespace or module to the current context.
from System.Windows import * from System.Windows.Controls import UserControl*
To access Silverlight-based class libraries from IronRuby
1.Use the require statement to load assemblies and to make their contents available for inclusion.
require MyAssembly
2.Use the include statement to add namespaces to the current context.
include System.Windows
この人のBLOG(http://www.iunknown.com/2008/03/dynamic-silverl.html)に詳細な説明がありますが
このへんは、せろりが詳しそうなのでせろりに教えてもらいます。