Rx: Bing Translate Example

In his Rx session at PDC09 Eric Meijer gave a nice example named Bing Translate. It was connecting to Bing via the Bing Web Service API and translated some term given by the user. It was quite interesting because Eric used the Reactive Framework for handling the translation and did some composition of the incoming results. He took just the first 2 translations and discarded the others. This didn’t make much sense, but it was ok for demonstration purposes. As followup Somasegar described the example in his blog.

But there was a lack of the whole sourcecode (btw: Eric Meijer posted it now on the Rx forum, but not as VS solution) and so I implemented it on my own with some modifications and now I want to share the whole Visual Studio solution with you.

Live demo

I’ve put my Bing Translate example as SL3 application on Windows Azure at http://bingtranslate.cloudapp.net, where you can directly test it:

Rx Bing Translate Example - Reactive Extensions - Reactive Framework

Sourcecode requirements

Since the Bing Translate example uses the Bing Web Service API, you need to get a free AppId here. Additional information on the Bing API can be found on the Bing Developer Center. When you’ve obtained your AppId, insert it into the BingService.cs file (field AppId of class BingService) of the sourcecode below. Now you should be able to run the solution.

What you furthermore need to open and run the solution:

  • Visual Studio 2008
  • Silverlight 3 SDK
  • Reactive Extensions for SL3 (latest release)

Now give me the code!

Ok, you want it, you get it 😉

[Visual Studio Solution for Silverlight 3 (ZIP)]

Notes on the code:

  • Contrary to Eric’s solution, mine will not synchronize the translation events when using the SetUpTranslationService() method in the MainPage.xaml.cs file. Use the SetUpTranslationServiceWithJoin() method if you want to have some synchronization. The main advantage of Rx is the composition of event streams, so this synchronization shows how simple things could be.
  • The code’s style is not expressing my real coding skills. Since this is just an example project, I did not make it stylish and bullet-proof.

That’s it! Have fun and please feel free to give me feedback.

kick it on DotNetKicks.com