Silverlight plus Live Mesh brings the Microsoft cloud to the desktop
Starting a new project
A new Mesh project does not just live in Visual Studio, it also has to be
uploaded to Microsoft’s servers. This involves visiting the Developer Portal
website and starting a new Live Framework project there (see screen 3). Once
created, the website invites you to upload a package. This does not yet exist,
so it is time to fire up Visual Studio, choose File, New Project, and select a
Visual Basic, Live Framework, Silverlight Mesh-enabled application.
This wizard creates a Hello World Silverlight application, but when you hit debug you will see a difference. Instead of running it in a web page, Visual Studio displays a dialogue telling you to upload a zip package to the Developer Portal.
Click the shortcut to copy the part to the package, then go to the project page, click Browse to upload a package,paste in the path, and upload it. Refresh the page, and in the Web Site Embedding section you will see a URL called Application Self Link. Copy this URL, which represents the online location of the new app, back into the Visual Studio dialogue and click OK. Visual Studio will now update the online version whenever you debug.
Writing the application
The application is like any other Silverlight app except that it has access to
Mesh services. At heart, Mesh data lives in collections of objects usually
published as RSS-like Atom feeds. The Live Framework SDK includes .Net libraries
that wrap these feeds in convenient .Net classes. However, they are in a
standard format, so in principle you can code Mesh apps as Javascript browser
apps, or as Java, Actionscript for Flash, or native Windows applications.
This simple to-do list app needs a data feed with text entries. The code-behind file for the Silverlight page declares a global variable representing this feed. In the MeshAppLoaded event, it tries to retrieve a reference to PCWListFeed, and if it fails, it creates it. Here is the code for creating the feed:
Dim meshApp As MeshApplicationService =
Application.Current.GetMeshApplicationService()
meshApp.DataFeeds.Add(New DataFeed(‘PCWListFeed’))
Once created, the following code retrieves a reference to the feed using Linq
(Language Integrated Query) and stores it in the df global variable:
Dim meshApp As MeshApplicationService =
Application.Current.GetMeshApplicationService()
df = (From dataFeed In meshApp.CreateQuery(Of DataFeed)() _
Where dataFeed.Resource.Title = ‘PCWListFeed’ _
Select dataFeed).FirstOrDefault
Related articles
Q.Why are some of the keys on my keyboard doing strange...
Q.Is my phone’s Bluetooth any use?
Q.Can I switch boot drives so that I can work on older...
Old Street roundabout is being touted by the Government as the UK's answer to Silicon Valley, but it seems our best innovations are coming from all over the UK
|
|
|
|
|
Computeractive Excel (2010) Online tutorialPrice: £19.99 |
Computeractive Word (2010) Online TutorialPrice: £19.99 |
Computeractive Powerpoint (2010) Online TutorialPrice: £19.99 |
Angry BirdsPrice: £9.99 |
Back Issue CD-Rom 14 (2011)Price: £15.99 |