G
Greg Duncan
Guest
Todays project is one by a Friend of Channel 9, Scott Lovegrove. Microsofts Live SDK is the primary means with which you can connect your programs or apps to the Live services. SkyDrive, Outlook.com (and Skype too).
Cloud documents, photos, calendars, messaging, contacts, friends and more are all available for you to integrate into your apps via the Live SDK.
Scotts taken the Live SDK and created a portable library that helps you ingrate it even faster and easier!
Belatedly Introducing LiveSDKHelper
A while back I was working on a project that allowed me to actually look at, and use, the Live SDK in order to access information on SkyDrive. I was surprised to find just how hard it was to use the Live SDK, so as part of building the main project, I also built a little helper for using the Live SDK.
The Solution
So what is the LiveSDKHelper? Well basically, it’s a collection of classes, enums and strings that just take the chore out of using the Live SDK. It’s a portable class library that works with both Windows Phone (7.5 and 8) and Windows 8. But you probably assumed that, right!
Onto some code! In Windows Phone, as part of the Live SDK, we are given a signin button control that we can use to enable our end users to sign into their Microsoft Account. This button requires you to give it some scopes so the user knows exactly what information your app wants to access. This is the first part of the helper:
//wl.basic wl.signin wl.offline_access wl.skydrive_update wl.calendars
var scopes = new List
{
Scope.Basic,
Scope.SignIn,
Scope.OfflineAccess,
Scope.SkyDriveUpdate,
Scope.Calendars
};
SignInButton.Scopes = scopes.ToConcatenatedString(
scope => scope.ToStringScope(),
" ");
So no more remembering what each scope’s string was.
Within the library are a number of constants for you to use in order to access certain parts of the Live SDK, like your Skydrive root folder, or your photos folder, or to get your friends. For example:
var result = await _client.GetAsync(MeDetails.MyFriends);
This makes it really easy to make sure you’re putting the right strings into the client calls.
But what about the responses? Some of the posts I’ve seen create dynamic objects based on the results, but what if you want something a bit more concrete? Well in all the responses back from the client is a property called RawResult, which is basically a JSON object that can be deserialized with your favourite deserializer. What my library gives you is a set of concrete classes that you can use in order to deserialize those results. Again, some code:
...
Again, this just makes it so much easier to deal with. And there’s plenty more to explore. At the moment, the library covers SkyDrive, Calenders and contacts.
If you want to give it a go, it’s installable from nuget.
The source for it is all on GitHub, and if you want to see an app using it, check out Store Card Buddy.
[GD: I cribbed 99% of Scotts post, with his permission... [Broken External Image]:http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif?v=c9 ]
Grabbing the latest drop from github, it complied and ran with no problems, the very first time (you know how much I love that). Heres a snap of the Solution;
Lets focus on the meat, the LiveSDKHelper. One thing I like was the references/dependences (or lack thereof).
That minimal dependency list should make the Helper much easier to us across all your projects, from both a coding and a licensing concern.
Here are some snaps of the Playground app running;
(Yeah, thats a little sad... um... yeah... [Broken External Image]:http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif?v=c9
One area that caught my eye was the SkyDriveHelper and folder;
Theres just something about building SkyDrive integration into my apps that I dig. Ive been wanting to do it for years. Now its not only possible, but highly encouraged and supported!
Want to see in action? Then check out Scotts Store Card Buddy app.
Heres a snap of it running on my system;
And a snip of code;
While you might not need Scotts LiveSDKHelper, its likely that if you are going to be using the Live SDK youre already written something like it, so why write it yourself when Scotts already done some of the dirty work? [Broken External Image]:http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif?v=c9
Continue reading...
Cloud documents, photos, calendars, messaging, contacts, friends and more are all available for you to integrate into your apps via the Live SDK.
Scotts taken the Live SDK and created a portable library that helps you ingrate it even faster and easier!
Belatedly Introducing LiveSDKHelper
A while back I was working on a project that allowed me to actually look at, and use, the Live SDK in order to access information on SkyDrive. I was surprised to find just how hard it was to use the Live SDK, so as part of building the main project, I also built a little helper for using the Live SDK.
The Solution
So what is the LiveSDKHelper? Well basically, it’s a collection of classes, enums and strings that just take the chore out of using the Live SDK. It’s a portable class library that works with both Windows Phone (7.5 and 8) and Windows 8. But you probably assumed that, right!
Onto some code! In Windows Phone, as part of the Live SDK, we are given a signin button control that we can use to enable our end users to sign into their Microsoft Account. This button requires you to give it some scopes so the user knows exactly what information your app wants to access. This is the first part of the helper:
//wl.basic wl.signin wl.offline_access wl.skydrive_update wl.calendars
var scopes = new List
{
Scope.Basic,
Scope.SignIn,
Scope.OfflineAccess,
Scope.SkyDriveUpdate,
Scope.Calendars
};
SignInButton.Scopes = scopes.ToConcatenatedString(
scope => scope.ToStringScope(),
" ");
So no more remembering what each scope’s string was.
Within the library are a number of constants for you to use in order to access certain parts of the Live SDK, like your Skydrive root folder, or your photos folder, or to get your friends. For example:
var result = await _client.GetAsync(MeDetails.MyFriends);
This makes it really easy to make sure you’re putting the right strings into the client calls.
But what about the responses? Some of the posts I’ve seen create dynamic objects based on the results, but what if you want something a bit more concrete? Well in all the responses back from the client is a property called RawResult, which is basically a JSON object that can be deserialized with your favourite deserializer. What my library gives you is a set of concrete classes that you can use in order to deserialize those results. Again, some code:
...
Again, this just makes it so much easier to deal with. And there’s plenty more to explore. At the moment, the library covers SkyDrive, Calenders and contacts.
If you want to give it a go, it’s installable from nuget.
The source for it is all on GitHub, and if you want to see an app using it, check out Store Card Buddy.
[GD: I cribbed 99% of Scotts post, with his permission... [Broken External Image]:http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif?v=c9 ]
Grabbing the latest drop from github, it complied and ran with no problems, the very first time (you know how much I love that). Heres a snap of the Solution;
Lets focus on the meat, the LiveSDKHelper. One thing I like was the references/dependences (or lack thereof).
That minimal dependency list should make the Helper much easier to us across all your projects, from both a coding and a licensing concern.
Here are some snaps of the Playground app running;
(Yeah, thats a little sad... um... yeah... [Broken External Image]:http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif?v=c9
One area that caught my eye was the SkyDriveHelper and folder;
Theres just something about building SkyDrive integration into my apps that I dig. Ive been wanting to do it for years. Now its not only possible, but highly encouraged and supported!
Want to see in action? Then check out Scotts Store Card Buddy app.
Heres a snap of it running on my system;
And a snip of code;
While you might not need Scotts LiveSDKHelper, its likely that if you are going to be using the Live SDK youre already written something like it, so why write it yourself when Scotts already done some of the dirty work? [Broken External Image]:http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif?v=c9
Continue reading...