TL54: Natural Interop With Silverlight, Office, And Python In ...

TL54: Natural Interop With Silverlight, Office, And Python In ...

TL54 TL54: Natural Interop With Silverlight, Office, And Python In Microsoft Visual C# And Microsoft Visual Basic Alex Turner C# Compiler Program Manager Microsoft Corporation Natural Interop With Diverse Object Models C# and Visual Basic were designed to work great with .NETs strongly-typed libraries.

However, there are many other object models out there that rely on specific features from their original target language! C# Visual Basic HTML DOM .NET BCL COM Python Libs HTML DOM Expects Dynamic Dispatch from JScript

JScript: var loc = new VELatLong(latitude, longitude); var pin = map.AddPushpin(loc); pin.SetTitle(title); pin.SetDescription(description); map.SetCenterAndZoom(loc, 7); C# 3.0 (Silverlight): ScriptObject loc = win.CreateInstance( "VELatLong", latitude, longitude) ScriptObject pin = (ScriptObject)map.Invoke("AddPushpin", loc); pin.Invoke("SetTitle", title); pin.Invoke("SetDescription", description); map.Invoke("SetCenterAndZoom", loc, 7);

COM Expects Named & Optional Params from VBA VBA: Selection.PasteSpecial Link:=True VB.NET: word.Selection.PasteSpecial(Link:=True) C# 3.0: object missing = Type.Missing; object link = true; word.Selection.PasteSpecial( ref missing, ref link, ref missing,

ref missing, ref missing, ref missing, ref missing); Python Libraries Expects Dynamic Dispatch from Python Python: import random random.shuffle(items) C# 3.0: var source = engine. CreateScriptSourceFromFile(@"lib\ random.py"); var scope = engine.CreateScope(); source.Execute(scope);

scope.SetVariable("items", items); var source1 = engine.CreateScriptSourceFromString( "random.shuffle(items)"); source1.Execute(scope); demo Silverlight HTML DOM Interop Natural Interop With HTML DOM In C# 4.0 JScript: var loc = new VELatLong(latitude, longitude); var pin = map.AddPushpin(loc);

pin.SetTitle(title); pin.SetDescription(description); map.SetCenterAndZoom(loc, 7); C# 4.0 (Silverlight): dynamic loc = win.New.VELatLong(latitude, longitude) var pin = map.AddPushpin(loc); pin.SetTitle(title); pin.SetDescription(description); map.SetCenterAndZoom(loc, 7); Natural Interop With HTML DOM In VB 10 JScript: var loc = new VELatLong(latitude, longitude);

var pin = map.AddPushpin(loc); pin.SetTitle(title); pin.SetDescription(description); map.SetCenterAndZoom(loc, 7); VB 10 (Silverlight): Dim loc As Object = win.New.VELatLong(latitude, longitude) Dim pin = map.AddPushpin(loc) pin.SetTitle(title) pin.SetDescription(description) map.SetCenterAndZoom(loc, 7) demo Office

COM Interop Natural Interop With COM In C# 4.0 VBA: Selection.PasteSpecial Link:=True VB.NET: word.Selection.PasteSpecial(Link:=True) C# 4.0: word.Selection.PasteSpecial(Link: true); demo IronPython

Using Dynamic Language Libraries Natural Interop With Python Libs In C# 4.0 Python: import random random.shuffle(items) C# 4.0: dynamic random = python.UseFile("random.py"); random.shuffle(items); Natural Interop With Python Libs In VB 10 Python:

import random random.shuffle(items) VB 10: Dim random As Object = python.UseFile("random.py") random.shuffle(items) Natural Interop With Diverse Object Models C# 4.0 and Visual Basic 10 have added features expected by other object models:

Named/optional parameters and omit ref in C# to support COM Dynamic dispatch in VB and C# to support the HTML DOM and Python libraries .NET BCL C# Visual Basic HTML DOM COM Python Libs

Online Resources C# Future Download Page: http://code.msdn.microsoft.com/csharpfuture SilverlightStarter project available in the CSharpDynamicSamples download VB Future Download Page: http://code.msdn.microsoft.com/vbfuture IronPython CTP Release:

http://go.microsoft.com/fwlink/?LinkId=129196 Related Sessions Upcoming sessions: TL12: Future Directions for Microsoft Visual Basic

TL57: A Panel on the Future of Programming Languages G. Bracha, D. Crockford, A. Hejlsberg, E. Meijer, W. Schulte, J. Siek Wed 10/29 | 10:30 AM-11:45 AM | 403AB TL16-R: The Future of C# Paul Vick

Tue 10/28 | 5:15 PM-6:30 PM | 406A Anders Hejlsberg Repeat: Wed 10/29 | 3:00 PM-4:15 PM | 502A Past sessions to watch online: TL10: Deep Dive: Dynamic Languages in .NET Jim Hugunin Evals & Recordings ll

fi e s a e l P r out you for n o ti a u l

eva t: a n o i s s this se This sess ion will be availa ble as a record ing at:

www.microsoftpdc.com QA & Please use the microphones provided 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Recently Viewed Presentations