First looks at the Live Framework SDK

I took some time to create the MyPhotos sample for the Live Framework SDK (currently in CTP).

I’m impressed with the consistency of the programming model.  You can get quite a bit done using just a few objects: A LiveOperatingEnvironment, Mesh, MeshObject, and DataFeed.

In only a few pages of code, I’ve got a desktop application that allows me to create folders in the mesh, upload pictures, and search for them.

the code looks amazingly familiar to any C# developer (I wrote is C#. I believe any VB.NET developer would say the same about the VB.NET version).

There are a few items to point out in the API.  this method shows how you can create a query to find data feeds in a given mesh object. It returns any mesh Files in a single mesh object:

   1: DataFeed GetFileDataFeed(MeshObject meshObject)
   2: {
   3:     DataFeed theDataFeed = (from dataFeed in meshObject.CreateQuery<DataFeed>()
   4:                             where dataFeed.Resource.Title == LIVE_MESH_FILES
   5:                             select dataFeed).FirstOrDefault<DataFeed>();
   6:  
   7:     return theDataFeed;
   8: }

It’s as simple as running a query against the mesh object.  more importantly, the CreateQuery<T>() method returns a LiveQuery<T> object, and LiveQuery<T> implements IQueryProvider!  All the query execution will happen at the server. The live framework parses the query and minimizes the traffic by pushing logic to the cloud rather than pulling data to query from the cloud.

As you explore the rest of the Live APIs you’ll find that many of the APIs that search for data in the cloud make use of IQueryProvider.

Creating objects is as simple as adding them to the correct collection.  Also, you can add other properties to the resource collection associated with an object. It’s four lines of code to upload and annotate a picture with a rating:

 

   1: DataEntry dataEntry = theDataFeed.DataEntries.Add(filestream, filename);
   2:  
   3: // Add user data (ratings) to data entry
   4: dataEntry.Resource.SetUserData<Ratings>(theRating);
   5:  
   6: // Required to see user data on all devices/Live Desktop/Data Model Browser
   7: dataEntry.Update();
   8:  
   9: // Make sure everyone is synchronized
  10: theDataFeed.SyncEntries.Synchronize();
  11: theDataFeed.Update();

More coming soon… There’s cloud applications in my future.

Published 21 January 2009 04:32 PM by wwagner
Ads by Lake Quincy Media

Comments

# Dennis Burton said on 26 January, 2009 10:29 AM

I was under the impression that a Live Mesh app would run disconnected from the mesh. Have you tried running this app with no network connectivity? I am curious if the query really does run in the cloud.

# Bill Blogs in C# said on 09 April, 2009 10:13 PM

I’ll start this post with a couple caveats. I’m learning the Live Framework SDK, just everyone else.

Search

Go

Blog Group Links

Nascar style badges