Wow. That was a fun talk that Jim and I did at Mix.
For the Ruby fans in the audience, here was the final version of the application that we wrote:
# This downloads a compiled C# assembly that contains a Button
require 'Silverlight.Samples.Controls,Version=0.0.0.0'
# This imports a JS and a VB module that each contain code that we will use
JS = require '3DText.js'
VB = require 'technorati.vbx'
# We don't have include working yet ...
Controls = Silverlight.Samples.Controls
Document = System.Windows.Browser.HtmlPage.Document
def initialize(sender, args)
# Create an instance of the downloaded C# button
b = Controls.Button.new
b.text = "Click Me"
JS.initialize
# Map Ruby block to .NET event from C#
b.click do |sender, args|
JS.clearList
# This uses a member injector to retrieve a reference to a HTML
# input element from the hosting HTML page
term = Document.searchTerm.value
# This retrieves data from Technorati via Yahoo Pipes serialized
# as JSON data, and then runs a LINQ over Objects query against it
items = VB.GetTitles(term)
# Blocks work, yay!
items.each { |item| JS.initializeName(item) }
# Play that funky designer animation
JS.playAnimation
end
root.Children.Add(b)
end
Keep in mind that the Ruby code here was done in about 4 weeks worth of dev time by our stud developer Tomas Matousek (of Phalanger fame, and my office-mate) with some random input from yours truly.