tomasslavicek

SkyDrive get login name

Sep 8th, 2012
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1.  
  2.         /// <summary>
  3.         /// Login of the user... (sign-in button)
  4.         /// </summary>
  5.         private void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
  6.         {
  7.             if (e.Status == LiveConnectSessionStatus.Connected)
  8.             {
  9.                 session = e.Session;
  10.                 infoTextBlock.Text = AppResources.sign1;
  11.                 client = new LiveConnectClient(e.Session);
  12.                 client.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(OnGetCompleted);
  13.                 client.GetAsync("me", null);
  14.             }
  15.             else
  16.             {
  17.                 infoTextBlock.Text = AppResources.sign2;
  18.                 client = null;
  19.             }
  20.         }
  21.  
  22.         void OnGetCompleted(object sender, LiveOperationCompletedEventArgs e)
  23.         {
  24.             // Prints information about logged user, displays button "continue"
  25.             if (e.Error == null)
  26.             {
  27.                 string firstName = "";
  28.                 string lastName = "";
  29.                 if (e.Result.ContainsKey("first_name") || e.Result.ContainsKey("last_name"))
  30.                 {
  31.                     if (e.Result.ContainsKey("first_name"))
  32.                         if (e.Result["first_name"] != null)
  33.                             firstName = e.Result["first_name"].ToString();
  34.  
  35.                     if (e.Result.ContainsKey("last_name"))
  36.                         if (e.Result["last_name"] != null)
  37.                             lastName = e.Result["last_name"].ToString();
  38.  
  39.                     infoTextBlock.Text = AppResources.sign1 + " " + firstName + " " + lastName;
  40.                 }
  41.                 else
  42.                     infoTextBlock.Text = AppResources.sign2;
  43.             }
  44.             else
  45.                 infoTextBlock.Text = AppResources.signError + e.Error.ToString();
  46.  
  47.             // Loads data from the net, displays buttons...
  48.             LoadData();
  49.         }
Advertisement
Add Comment
Please, Sign In to add comment