TL54: Natural Interop With Silverlight, Office, And Python In Microsoft Visual C# And Microsoft Visual Basic - PowerPoint PPT Presentation

anatole
slide1 l.
Skip this Video
Loading SlideShow in 5 Seconds..
TL54: Natural Interop With Silverlight, Office, And Python In Microsoft Visual C# And Microsoft Visual Basic PowerPoint Presentation
Download Presentation
TL54: Natural Interop With Silverlight, Office, And Python In Microsoft Visual C# And Microsoft Visual Basic

play fullscreen
1 / 20
Download Presentation
TL54: Natural Interop With Silverlight, Office, And Python In Microsoft Visual C# And Microsoft Visual Basic
226 Views
Download Presentation

TL54: Natural Interop With Silverlight, Office, And Python In Microsoft Visual C# And Microsoft Visual Basic

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. 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

  2. Natural Interop With Diverse Object Models • C# and Visual Basic were designed to work great with .NET’s 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

  3. HTML DOMExpects 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);

  4. COMExpects Named & Optional Params from VBA • VBA: • VBA: • Selection.PasteSpecialLink:=True • Selection.PasteSpecialLink:=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);

  5. Python LibrariesExpects 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);

  6. demo SilverlightHTML DOM Interop

  7. Natural Interop With HTML DOMIn 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);

  8. Natural Interop With HTML DOMIn 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)

  9. demo OfficeCOM Interop

  10. Natural Interop With COMIn C# 4.0 • VBA: • Selection.PasteSpecialLink:=True • VB.NET: • word.Selection.PasteSpecial(Link:=True) • C# 4.0: • word.Selection.PasteSpecial(Link: true);

  11. demo IronPythonUsing Dynamic Language Libraries

  12. Natural Interop With Python LibsIn C# 4.0 • Python: • import random • random.shuffle(items) • C# 4.0: dynamic random = python.UseFile("random.py"); random.shuffle(items);

  13. Natural Interop With Python LibsIn VB 10 • Python: • import random • random.shuffle(items) • VB 10: Dim random As Object = python.UseFile("random.py") random.shuffle(items)

  14. 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 supportthe HTML DOMand Python libraries C# Visual Basic .NET BCL HTML DOM COM Python Libs

  15. Online Resources • C# Future Download Page: • http://code.msdn.microsoft.com/csharpfuture • SilverlightStarter project available in the CSharpDynamicSamplesdownload • VB Future Download Page: • http://code.msdn.microsoft.com/vbfuture • IronPython CTP Release: • http://go.microsoft.com/fwlink/?LinkId=129196

  16. Related Sessions • Upcoming sessions: • TL12: Future Directions for Microsoft Visual Basic • Paul Vick • Tue 10/28 | 5:15 PM-6:30 PM | 406A • 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# • 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

  17. Evals & Recordings Please fill out your evaluation for this session at: This session will be available as a recording at: www.microsoftpdc.com

  18. Q&A Please use the microphones provided

  19. © 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.